jeffijoe / mobx-task

Makes async function state management in MobX fun.
MIT License
238 stars 6 forks source link

Upgrade to MobX v6 #50

Closed jeffijoe closed 2 years ago

jeffijoe commented 2 years ago

Upgrades to the library to support MobX 6. We had to wrap the task in an action to prevent MobX from automatically converting it to an action.

BREAKING CHANGE: The decorator will break when a MobX decorator is used on the same method.

Closes #32

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling f2f25786850e2b61cc1895e9d25ebfa2aab6c337 on mobx-6 into 24704082d91723e51bc8b426d3181e0ac5e02217 on master.

jeffijoe commented 2 years ago

:tada: This PR is included in version 3.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

kkollman commented 2 years ago

@jeffijoe Awesome news! Does it work with mobx's makeObservable method?

jeffijoe commented 2 years ago

I am not sure since I haven't used it, but I don't see why not, try it out and let me know!

kkollman commented 2 years ago

Yeah, I checked it and unfortunately, it doesn't - mobx throws an Invalid annotation error. If I find any solution, I'll post it here

jeffijoe commented 2 years ago

My recommendation is to use property initializers like this:

class MyClass {
  myTask = task(async () => ...)
}
kkollman commented 2 years ago

Thank you, that is what I'll do!