-
Notifications
You must be signed in to change notification settings - Fork 11
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
Restartable compromises symbol-observable interop #67
Comments
I have a fix for this working locally for my use-case, but it relies on some newer ES functionality. In my specific case we're looking for interop with Symbols, which should only exist in ES2015 anyway, so I'd be okay with a polyfill for some of this functionality. Without a polyfill, the tests relying on the behavior break. Here's the gist of my potential solution (not the whole thing). Before I commit and submit a PR, is there any more discussion that we should have on this? function keys (obj) {
const _keys = [];
for (const prop in obj) {
_keys.push(prop);
}
// get all of the symbols on the object
for(const prop of Object.getOwnPropertySymbols(obj) ) {
_keys.push(prop);
}
// get all of the symbols on the prototype
for(const prop of Object.getOwnPropertySymbols(Object.getPrototypeOf(obj) || {}) ) {
_keys.push(prop);
}
return _keys;
} Would appreciate your thoughts when you have time @Widdershin. Also note that breakages don't affect anything in the monorepo, but they will affect CycleJS flavors that use restartable out of the box (like |
Thanks for the bug report and potential fix. The route you're investigating
makes a lot of sense, I'd love a pull request if you have the time.
Personally I would be fine with cycle-restart only working in modern
browsers, since it's a dev tool. Although I guess maybe it might be useful
in browsers without native symbols?
Personally I'm happy with either requiring users to have greenfields
browsers or including a polyfill.
…On Sat, Dec 16, 2017 at 10:18 AM, Christian Johns ***@***.***> wrote:
I have a fix for this working locally for my use-case, but it relies on
some newer ES functionality. In my specific case we're looking for interop
with Symbols, which should only exist in ES2015 anyway, so I'd be okay with
a polyfill for some of this functionality.
Without a polyfill, the tests relying on the behavior break. Here's the
gist of my potential solution (not the whole thing). Before I commit and
submit a PR, is there any more discussion that we should have on this?
function keys (obj) {
const _keys = [];
for (const prop in obj) {
_keys.push(prop);
}
// get all of the symbols on the object for(const prop of Object.getOwnPropertySymbols(obj) ) {
_keys.push(prop);
}
// get all of the symbols on the prototype for(const prop of Object.getOwnPropertySymbols(Object.getPrototypeOf(obj) || {}) ) {
_keys.push(prop);
}
return _keys;
}
Would appreciate your thoughts when you have time @Widdershin
<https://github.com/widdershin>. Also note that breakages don't affect
anything in the monorepo, but they will affect CycleJS flavors that use
restartable out of the box (like one-fits-all). CC @jvanbruegge
<https://github.com/jvanbruegge>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#67 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAYUHTNhmuwtb4l3nQZShks8_Qe4feL0ks5tAuIHgaJpZM4RD6We>
.
|
Ensure properties that are symbols are included in streams wrapped by cycle-restart. Many stream libraries are using symbols to standardize interoperability between one another. When transforming streams as part of cycle-restart, it is important to retain all behavior that is present on the stream or on its prototype. This change includes a shim for Object.getOwnPropertySymbols, which is used to retrieve all symbols from an object. Resolve Widdershin#67.
Test the preservation of symbol properties when driver functions are wrapped by restartable. Note, these tests don't verify that prototype properties on xstream are preserved because it would require adding a dependency on symbol-observable. Additionally, the specific bug being tested is only introduced we sinks are recreated property-by-property. This doesn't happen with xstream sinks. Related to Widdershin#67.
PR is up @Widdershin, I included a shim. Open to feedback - I tried to keep the diff small. |
When iterating on source properties in restartable,
symbol-observable
support is compromised.This means the following code won't work:
The error is specifically that
source$
does not have a property fromsymbol-observable
that is added byxstream
for interop with different stream libraries.I think this is related to #55, but is slightly different since it isn't about a problem with driver methods/props, but with source/sink props.
To test that this can work, just wrap a driver (DOM sources from
@cycle/dom
are an acceptable candidate), and test that the property exists.Also,
symbol-observable
is just one case, this would be true of all properties that relied on symbols or supported custom features on streams. But it's just an example of the broader problem.Happy to help work on this @Widdershin, and submit the PR, but it looks like you may have started some work already as part of the Cycle Unified milestone? Let me know how I can help, and I'll get on it.
The text was updated successfully, but these errors were encountered: