Make `preSnapshot` and `postSnapshot` actions in middleware ?
Feature request
Make implementing preSnapshot and postSnapshot implementable by middleware.
Is your feature request related to a problem? Please describe.
- I have some models that describe user files. In order to serialize this data I need to access some global state that I might want to redefine depending on the environment. (E.x., A database interface, a file interface). In order to do this now I would have to set up a complicated set of model builders that take my interface as arguments and build the models.
- Sometimes I would like to serialize/deserialize a node based on information in the parent.
- It would be nice to be able to globally change how serialization is handled for other reasons. For example, I have a lot of models that are
optionaland those are automatically serialized asnullwhen empty instead of just being omitted. With a middleware I could globally change that behavior without having to add processors to every model or request the change in MST.
See also: #662
Describe the solution you'd like
Currently, middleware does not get the preSnapshot or postSnapshot actions.
- Report those actions to middleware.
- Use the snapshot returned by the middleware to serialize/deserialize.
Describe alternatives you've considered
- Manually applying pre/post snapshot to every model.
- Generating models in functions.
Are you willing to (attempt) a PR?
- [ ] Yes
- [ ] No
- [x] Maybe
Hey @nspaeth - I am sorry it took so long for us to get back to you here.
I think this is a good idea, although I'm not exactly sure where it'll land on the roadmap. I am going to mark this issue as PR welcome, but if you've moved on from the thought, I totally understand. It's been almost eighteen months!
Let me know if you're interested in putting something like this together. If not, I'll leave it open for future contributors who have similar needs and want a starting point.
issue moved to : https://github.com/coolsoftwaretyler/mst-middlewares/issues/6
^ Sorry, that's my bad for miscommunicating. This issue is actually an mst feature, so we will not be moving it. Closing over there, leaving open here.