-
Notifications
You must be signed in to change notification settings - Fork 5
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
Introducing Scopes #102
base: main
Are you sure you want to change the base?
Introducing Scopes #102
Conversation
I think we need some additional docs for this change which details about how messages propagate up and down scopes. |
What are we doing about scope disposal. I think it needs to be part of this process. |
That's a good point, there should be a mechanism for disposing of a scope similar to what exists for channels. This also made me realise another point - given that messages on a channel trickle down to the same channel in child scopes, the existing disposal logic should dispose of the same channel in the children. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor suggestions. Where do we stand on destroy or scopes?
Yes sorry I had forgotten about the scope destroying my bad. My interpretation of this would be to have the ability to disconnect the child of an instance that you have, e.g. const broker1 = messagebroker<Contract>();
const broker2 = broker1.createScope('my-scope');
broker1.destroyScope('my-scope');
broker2.get('channel').subscribe(_ => console.log('hello!'));
broker1.create('channel').publish('test'); // nothing happens so it's essentially orphaning the child broker, stopping any message propagation down to it. What do you think, is this the kind of thing you had in mind or am I misunderstanding? |
I have added the concept of Scopes to the MessageBroker. This is a mechanism for building a tree of message brokers in which messages will propagate up the tree until either the root is reacher, or a broker is found which has a subscriber to handle the message.
One outstanding question on this implementation is if the semantics for disposing of a scope is complete. Currently you can
.destroy()
a broker, which will unlink it from its parent meaning messages will no longer propagate up. Should this functionality do anything else? E.g. should it unlink itself from any children scopes as well?