Skip to content

Conversation

@j0ran
Copy link

@j0ran j0ran commented Jul 15, 2019

No description provided.

@janwilmans
Copy link
Member

@j0ran thanks for your pull request, you say this is a simplified for which a better solution exists, could you describe what the better solution is and in what cases the simpler solution doesn't work or becomes impractical? I'm not sure when to use the Invariant pattern you described.

@j0ran
Copy link
Author

j0ran commented Jul 15, 2019

In this case, you could, for example, make a timer that keeps sending timeouts until you stop it. Then you will receive unexpected timeouts if you don't stop the timer and no events if you don't start it.

When to use it? When you feel you can not ensure a certain invariant is being held. It really depends on the situation. I noticed when using this pattern that often I found another design that would ensure a certain invariant. But not always. I still use it for a component to ensure I am subscribed to status messages when it is operational or locked. The invariant pattern is just another tool in your toolbox.

Do you want me to add these explanations to the discussion in the README.md?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants