computed-async-mobx
computed-async-mobx copied to clipboard
Mobx 6 support
Hi, we're using computed-async-mobx (thanks for it!) and recently when trying to update to Mobx6 we encountered an error.
This prompted me to look into this repo and I see it's been a while since it was last updated, I wonder whether it's still maintained and if there are any plans to make it work with Mobx6?
Thanks!
Hi, the feature set being stable, updates are rarely needed, but it usually needs to be fixed up in some way for a new major version of MobX.
It would be great to get a PR for this, if you're interesting in making one!
Not sure if I'm familiar enough with the internals, both mobx itself and computed-async-mobx.
FWIW, from what I can see it comes down to the change of some reaction
methods/members to be internal
runReaction
, getDisposer
and isDisposed
used by autorunThrottled, have all been postfixed with underscore.
I couldn't find any info on upgrade path for these in the changelog, reaction.ts
is not of much help as well, having some outdated comments, like:
internal, use schedule() if you intend to kick off a reaction
but schedule
also has been marked as internal with underscore.
Please give version 6.0.0 of this library a try, see https://codesandbox.io/s/delicate-cherry-lozkc?file=/src/index.tsx
Thank you for that!
It does work in development indeed but I get an error once the app is built, it might be my build setup that's causing it, not sure, but wanted to just point it out in case anyone else also have issues with production builds.
In built version of the app I get
TypeError: r.runReaction_ is not a function
at Object.autorunThrottled
Well, that answers the question in the back of my mind (those underscores probably mean "don't use"!)... Probably need to go back to the drawing board.
One more thing, this new release breaks backwards compatibility with Mobx versions prior to Mobx6 because of the usage of makeObservable
which was introduced in v.6:
https://github.com/danielearwicker/computed-async-mobx/blob/ed21788011a65bc74f1e81d8d01050c90226c8cf/src/promisedComputed.ts#L1
but peerDependencies
suggest continuous support for older versions:
https://github.com/danielearwicker/computed-async-mobx/blob/ed21788011a65bc74f1e81d8d01050c90226c8cf/package.json#L25
When used with Mobx5 the user understandably gets following error:
Oh, that's much worse!
So I've abandoned the attempt for now. There's a 6.1.0 that is basically back how it was. Shame. Will try again when I get some time.
There is now 7.0.1-beta.1
, draft documentation here.
npm install computed-async-mobx@beta
I had to make some breaking changes (see docs) but hopefully not insurmountable.
The travis build now tests against MobX 4, 5 and 6.
@danielearwicker
Is there a plan to release this beta? We were using computed-async-mobx
with previous mobx
versions and would love to pick it into the newer project. Of course, we can't relay on the beta version in production.
Hello, do we have any new information about this issue? Do you think is it safe to use the beta version in a production build?