computed-async-mobx icon indicating copy to clipboard operation
computed-async-mobx copied to clipboard

Mobx 6 support

Open amytych opened this issue 4 years ago • 10 comments

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!

amytych avatar Oct 28 '20 09:10 amytych

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!

danielearwicker avatar Oct 29 '20 19:10 danielearwicker

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.

amytych avatar Nov 02 '20 08:11 amytych

Please give version 6.0.0 of this library a try, see https://codesandbox.io/s/delicate-cherry-lozkc?file=/src/index.tsx

danielearwicker avatar Dec 13 '20 17:12 danielearwicker

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

amytych avatar Dec 14 '20 15:12 amytych

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.

danielearwicker avatar Dec 14 '20 16:12 danielearwicker

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: image

amytych avatar Dec 14 '20 18:12 amytych

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.

danielearwicker avatar Dec 14 '20 19:12 danielearwicker

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 avatar Dec 30 '20 00:12 danielearwicker

@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.

maximkoretskiy avatar Aug 11 '21 16:08 maximkoretskiy

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?

lachezar-dimitrov avatar Aug 02 '22 07:08 lachezar-dimitrov