Comments (3)
Hey, thanks for the bug report. Non legacy babel decorator support should be fixed in the recently released 0.26.4 (let me know if it is not!).
Sadly @model
cannot be moved just as a name of Model since it needs to change the final extended class, the closest it could get is:
class _M extends Model(...) {}
export const M = model(_M, "name")
or similar
for the others (modelAction and modelFlow) it shouldn't be too difficult to change them to something like
{
someAction = modelAction("actionName", () => {....})
}
however it has a few downsides:
- it won't be able to get the action name automatically, so it would need to be specified again (duplicated)
- all actions would need to be specified as a class field rather than class method, so it wouldn't use the prototype (meaning each instance would have a copy of the function), which is a bit slower
I guess a way to avoid those two cons would be to turn model into a decorate alike thing:
class _M extends Model({...}) {
someAction() {...}
someFlow = _async(function *() {...})
}
export const M = model(_M, {
someAction: modelAction,
someFlow: modelFlow
})
I don't particularly like that syntax since that puts the "decorations" far from the decorated thing, but I see how that can be useful for people that don't want to deal with decorators. Would that last decorate idea be useful to you or is the fix to make it work with babel new decorators good enough?
from mobx-keystone.
Thanks for the quick response
The 0.26.4 fix works and is good enough for me 👍
The decorate idea is not as clean as decorators, but looking at the wider picture, I believe it would be viable alternative for people, who don't want to use decorators yet
However they can already use this approach:
const M = model("M")(_M)
decorate(M, { // from mobx
someAction: modelAction,
someFlow: modelFlow
})
I believe we can close this issue since bug is fixed and decorators will eventually make its way into the standard
from mobx-keystone.
Thanks for testing! Closing until there are more requests to support this then
from mobx-keystone.
Related Issues (20)
- Slow init HOT 4
- Non-observable model properties (like observable.ref) HOT 7
- Incorrect `this` scope depending how modelAction is passed into a component HOT 2
- How to Limit Undo Levels with undoMiddleware in mobx-keystone? HOT 1
- Tooling, devtools support HOT 4
- Supporting something like array.insert? HOT 2
- Unexpected value of context from detached node HOT 2
- Stream utilities on top of keystone HOT 3
- How to provide default/fixed value for inheriting class? HOT 4
- Mental model and idea behind keystone's tweaks/patches related to mobx observe
- Root Registry / Backrefs with deep observation HOT 5
- Keystone types supporting `onActionMiddleware` HOT 3
- Is it valid to start actions in onActionMiddleware's onStart/onFinish? HOT 2
- How to listen "initial" onPatches on RootStore?
- incorrect detaches from root store when applying snapshot HOT 4
- model does not detached from root store if it in array HOT 4
- Exception when detaching model that have active reaction with reference HOT 4
- Not able to access static methods of parent class from child class when inheriting with generic types. HOT 1
- Does it support Typescript 5.X features? HOT 3
- Unnecessary loops causes low performance, how to optimize the performance HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobx-keystone.