-
Notifications
You must be signed in to change notification settings - Fork 104
async setters? #82
Comments
This would be bizarre. This would mean that the value of |
To me, this seems like one of the many scenarios where getters and setters just aren't appropriate. Normal functions will work great here. |
Definitely not in this version, but it can be considered for the future. I tend to agree though that returning anything other than the rval from an assignment expression is very questionable. |
I can think of a scenario where this would make sense to do - running into one now, actually. I've made a Proxy which uses json-patch for isomorphism. The setters track modifications and eventually batch operations and sync with the server via json-patch. I think it would be useful to have the semantic of:
and something.first_name == promise until resolved, maybe: Perhaps async setters wouldn't enumerate as a property the same way others would, to avoid problems with JSON.stringify and such? My workaround for now is event dispatching, but doing that in 2020 feels very legacy. |
I stumbled on a strange issue where I needed to return a promise from a setter:
The getter works alright, since I can return a promise of a value from the getter, rather than the value. But this doesn't work with a setter, since I can't return anything from the setter. This means I can't await the writing of the file. This would work if the setter (and symmetrically the getter) could be async, like so:
Setters return the value being set in expressions, so
This could be tweaked for async setters, so they return a promise instead:
Has this been considered?
The text was updated successfully, but these errors were encountered: