Convenient way to initialize a state with data #38
johnrudolph
started this conversation in
Ideas
Replies: 1 comment
-
I think maybe the move would be two separate approaches for tests and production code. In tests, I think we should have the concept of state factories, so that you can get your state set up however you need for the tests without having to fire a bunch of events. For setting up state in production, though, I think it's really important that an event is fired—snapshots shouldn't be relied upon. So what if we had an internal |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would love a way to initialize a state, pass in whatever data I want into its variables, and then snapshot it so that I can have whatever starting point I want for a given state.
The main place this would be helpful for me would be in tests. For example, my dream situation would be if I could do something like this:
I also think this could be useful in other contexts like migrating a legacy system to event sourcing, where you need to create states for things that already exist and aren't starting fresh. You could essentially seed data into these states, snapshot them, and then go from there.
Beta Was this translation helpful? Give feedback.
All reactions