Moment - Custom Type? #292
-
We use moment.js to represent time. Looking at MST, the prescribed way to use something like Moment in MST models you would create a custom type like this:
Is there a prescribed way of doing this in |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
I think this is a use case mobx-keystone doesn't handle at the moment. There's discussion in these issues: #285 #275 |
Beta Was this translation helpful? Give feedback.
-
New property transforms + context apply/applyComputed were released as part of v0.61.0 Docs: Let me know if that solves your case completely/partially |
Beta Was this translation helpful? Give feedback.
-
Yes, it is there just for efficiency, in case you can re-use the transformed value (e.g. Date) passed to "new", a setter, etc. instead of creating a new one from the original value. It is an advanced use case though, so if unsure it is better not to use it.
Imagine that you want to return a custom Date object that whenever "setMilliseconds" is called it would modify the original (snapshot) value. That function would allow you to do that. |
Beta Was this translation helpful? Give feedback.
New property transforms + context apply/applyComputed were released as part of v0.61.0
Docs:
Let me know if that solves your case completely/partially