0no-co / wonka

🎩 A tiny but capable push & pull stream library for TypeScript and Flow
MIT License
709 stars 29 forks source link

Use a ponyfill observable instead of polyfilling #121

Closed gerarts closed 1 year ago

gerarts commented 2 years ago

Resolve #122

One of the issues users may run into in the current situation is that if Wonka is loaded after other Observable objects have already been created with the ponyfill method, Wonka will polyfill the Symbol.observable causing packages to no longer recognise previously created observables, breaking interoperability.

This PR makes sure Wonka's behaviour matches that of other packages like RxJS src/internal/symbol/observable.ts and redux src/utils/symbol-observable.ts.

gerarts commented 2 years ago

This fixes #122

gerarts commented 1 year ago

I have applied your suggestion. 👍

I think a lot of libs just copied the Symbol.observable polyfill implementation from either the proposal or RxJS, and it sort of spread through the 'copy-paste approach'.

It might be nice to add something to the docs / readme to explain how developers can manually polyfill Symbol.observable if they are running into trouble with other libs that do the same thing as wonka's current implementation.

Another alternative would be adding the old polyfill as a separate module to allow developers to import the legacy polyfill (something like import 'wonka/legacy-symbol-observable-polyfill'). This would also allow you to add a deprecation console.warn in the future.

Let me know if you'd like me to get on either of those.

kitten commented 1 year ago

re. the docs, they're not in a state yet where they can be edited again, but that's on my to-do list, but I'm hoping this will do for now

gerarts commented 1 year ago

Prettier was unhappy, should be good now

kitten commented 1 year ago

Resolves #122