Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make preSnapshot and postSnapshot actions in middleware ? #1861

Open
1 of 3 tasks
nspaeth opened this issue Jan 22, 2022 · 3 comments
Open
1 of 3 tasks

Make preSnapshot and postSnapshot actions in middleware ? #1861

nspaeth opened this issue Jan 22, 2022 · 3 comments
Labels
help/PR welcome Help/Pull request from contributors to fix the issue is welcome level: intermediate

Comments

@nspaeth
Copy link

nspaeth commented Jan 22, 2022

Feature request
Make implementing preSnapshot and postSnapshot implementable by middleware.

Is your feature request related to a problem? Please describe.

  1. 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.
  2. Sometimes I would like to serialize/deserialize a node based on information in the parent.
  3. 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 optional and those are automatically serialized as null when 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.

  1. Report those actions to middleware.
  2. Use the snapshot returned by the middleware to serialize/deserialize.

Describe alternatives you've considered

  1. Manually applying pre/post snapshot to every model.
  2. Generating models in functions.

Are you willing to (attempt) a PR?

  • Yes
  • No
  • Maybe
@coolsoftwaretyler
Copy link
Collaborator

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.

@coolsoftwaretyler coolsoftwaretyler added help/PR welcome Help/Pull request from contributors to fix the issue is welcome level: intermediate labels Jun 27, 2023
@zuhorer
Copy link

zuhorer commented Sep 19, 2023

issue moved to : coolsoftwaretyler/mst-middlewares#6

@coolsoftwaretyler
Copy link
Collaborator

^ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help/PR welcome Help/Pull request from contributors to fix the issue is welcome level: intermediate
Projects
None yet
Development

No branches or pull requests

3 participants