You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given an observable such as value.from( map, "promised.value" ) - internally reflectPromise is not used to make the promised property's result observable, if it returns something promise-like.
This is a major step back from using can.compute.read in older versions of CanJS, which did apply promise reflection transparantly.
One could argue not hooking up the behavior for performance reasons, but in that case I'd argue that it should be possible to look ahead to the next key in the chain ("value" in this case); to note that it's one of the special promise meta-keys; and to then selectively apply the reflectPromise hookup.
This problem is devilishly insidious, as reflectPromise ties itself to the passed promise's prototype, where possible.
This means if another totally unrelated promise that just happens to share its prototype, is accessed in a stache template (where reflectPromiseis auto-applied) - then 'magically' things work and you're not aware you've created a submarine bug.
Diagnosing that bug is hard and gets even worse when your code putting promises into stache templates is async and relies on network conditions -- e.g. separate components mounting from separate webpack chunks. At that point things may or may not 'magically' work, depending on non-deterministic order of execution.
The text was updated successfully, but these errors were encountered:
@justinbmeyer
That doesn’t strike me as true. We add to the instance, not the prototype.
The actual state storage is attached per-instance, but the symbols implementing the observability hooks themselves like can.getKeyValue and can.onKeyValue are attached to the prototype for prototype-based promises. (Those symbols then lazily initialize the state for individual instances on first-access.)
Given an observable such as
value.from( map, "promised.value" )
- internallyreflectPromise
is not used to make thepromised
property's result observable, if it returns something promise-like.This is a major step back from using
can.compute.read
in older versions of CanJS, which did apply promise reflection transparantly.One could argue not hooking up the behavior for performance reasons, but in that case I'd argue that it should be possible to look ahead to the next key in the chain ("value" in this case); to note that it's one of the special promise meta-keys; and to then selectively apply the
reflectPromise
hookup.As it stands, I'm now writing:
where really, I want to be writing:
This problem is devilishly insidious, as
reflectPromise
ties itself to the passed promise's prototype, where possible.This means if another totally unrelated promise that just happens to share its prototype, is accessed in a stache template (where
reflectPromise
is auto-applied) - then 'magically' things work and you're not aware you've created a submarine bug.Diagnosing that bug is hard and gets even worse when your code putting promises into stache templates is async and relies on network conditions -- e.g. separate components mounting from separate webpack chunks. At that point things may or may not 'magically' work, depending on non-deterministic order of execution.
The text was updated successfully, but these errors were encountered: