-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The syntax around inflight init
and inflight fields is misleading
#4564
Comments
Use case for inflight init and fields: winglang/winglibs#6 (review) having second thoughts about getting rid of this feature.. (maybe we can brainstorm on alternative syntaxes first...) |
I think that's the use case @yoav-steinberg was also referring to. |
yes, of course, that's the use case. |
See #3174 (comment) |
@yoav-steinberg I am not sure I understand how |
@eladb Sorry for the long answer: Now you can ask yourself, why isn't this a problem in regular OOP? If you have a class with So what's the difference? The answer is: explicit instantiation. When you call // In the following code I know I'm running Foo's ctor.
// In the following code I know I'm creating a new distinct, non-shared, non-static state inside the variable x.
let x = new Foo(); So now we want to translate that experience to lifting:
Here's the redis client example:
|
Great explanation, thanks @yoav-steinberg. |
Hi, This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
I'm leaning towards @staycoolcall911's suggestion to just be a rename to something like |
I am also comfortable not dealing with this at the moment. Maybe we can use some more experience with using these idioms before we change things. |
I tried this:
Consider this example:
A similar issue exists with inflight fields:
See #4561 (comment)
This happened:
You might expect that after invoking
f1
, thenf2
will return"hello"
, but it returns"initial message"
.This is because the inflight initializer is called once per client.
I expected this:
The purpose of inflight initializers and fields is to allow caching state within the inflight client of a resource.
Is there a workaround?
No response
Component
Language Design
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Anything else?
No response
Community Notes
The text was updated successfully, but these errors were encountered: