jeffijoe / mobx-task

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

Added support for fields with (arrow) functions #12

Closed JulianWielga closed 5 years ago

JulianWielga commented 5 years ago

I updated your readme assuming that this works.

jeffijoe commented 5 years ago

Could you verify it works with TS as well? I remember something about Babel and TS's decorator stuff being different regarding initializers.

JulianWielga commented 5 years ago

I've tested it in my project with @babel/typescript preset and @babel/plugin-proposal-class-properties with loose: true. Did you mean plain typescript compiler? I think it's impossible to decorate field holding function without babel.

A Property Descriptor is not provided as an argument to a property decorator due to how property decorators are initialized in TypeScript(...) https://www.typescriptlang.org/docs/handbook/decorators.html#property-decorators

jeffijoe commented 5 years ago

Aha, then it should be fine

JulianWielga commented 5 years ago

I think that if someone is using decorators or class properties holding arrow function and typescript knows what and how to do it and is prepared for problems :)

jeffijoe commented 5 years ago

Well, if someone encounters an issue with TS I’ll ping you 😄

Thanks for the PR, I’ll merge and publish tomorrow!

jeffijoe commented 5 years ago

Released as 1.0.3, thanks for your contribution! 🎉