How to judge a function is MST action #2046
Replies: 2 comments
-
Hey @BanShan-Alec - I have a few thoughts. I found your CodeSandbox and have been playing around with it.
function isValidAction(actionName, model) {
return typeof model[actionName] === "function";
} Of course, that won't give you the precise answer, since other items on the model instance might be functions as well, such as views. You mentioned in the MobX discussion that you are using some MST internals as a workaround. Would you be willing to:
I'd definitely be interested in a PR to add something like this. I have been unable to find a really good out-of-the-box solution as-is. Final note here, I think this might be somewhat related to a longstanding issue we closed out about distinguishing actions and properties. There is an underlying philosophy here to keep things simple, so I don't think we need to rework anything, but if you found a path forward from reading an internal, there's probably a way for us to write a stable API to surface that information. |
Beta Was this translation helpful? Give feedback.
-
I'm going to go ahead and mark this as closed since it's been a while without a response. Feel free to re-open! |
Beta Was this translation helpful? Give feedback.
-
when I use mobx-state-tree,I need judge a function is MST action. After reading MST Document,I can not find a api to resolve it.
So I make a question issue in mbox repo, they suggest me to seek help at here.
mobxjs/mobx#3726
Beta Was this translation helpful? Give feedback.
All reactions