You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A message should be able to be published within a given scope, such that only a subscriber who has access to the messagebroker of that scope will be notified of the published message.
There should be a new instance of the broker for each scope, as opposed to reusing the same global reference.
The trouble here would be registering the necessary instances against the tokens so that they're there when someone tries to inject it... Might need some input from you @Davidhanson90 on how this could work from the Needle point of view
Example
Note the scopes are the same
constbroker1=messagebroker<IContracts>('scope-1');constbroker2=messagebroker<IContracts>('scope-1');// should return the same instancebroker1.get('some-channel').subscribe(_msg=>console.log('Loud and clear!'));broker2.create('some-channel').publish('Is anyone receiving?');// 'Loud and clear!' is logged to the console
now we use separate scopes
constbroker1=messagebroker<IContracts>('scope-1');constbroker2=messagebroker<IContracts>('scope-2');// returns a different instancebroker1.get('some-channel').subscribe(_msg=>console.log('Loud and clear!'));broker2.create('some-channel').publish('Is anyone receiving?');// nothing is logged to the console
The text was updated successfully, but these errors were encountered:
With it being a tree structure, I suppose it would make sense for the child scopes to see the messages from their parent, like this:
it('should publish messages to children from parent',()=>{constparentMessages: Array<IMessage<string>>=[];constchildMessages: Array<IMessage<string>>=[];constparent=getInstance();constchild=parent.createScope('scope1');parent.get('channel').subscribe((message)=>parentMessages.push(message));child.get('channel').subscribe((message)=>childMessages.push(message));parent.create('channel').publish('both should get this');child.create('channel').publish('only the child should get this');expect(parentMessages.length).toEqual(1);verifyMessage(parentMessages[0],'both should get this');expect(childMessages.length).toEqual(2);verifyMessage(childMessages[0],'both should get this');verifyMessage(childMessages[1],'only the child should get this');});
A message should be able to be published within a given scope, such that only a subscriber who has access to the messagebroker of that scope will be notified of the published message.
There should be a new instance of the broker for each scope, as opposed to reusing the same global reference.
How does a user get an instance?
An overload of the existing factory method?
How would the dependency injection work? Is there a feature of Needle that can help us here, such as injecting by token?
The trouble here would be registering the necessary instances against the tokens so that they're there when someone tries to inject it... Might need some input from you @Davidhanson90 on how this could work from the Needle point of view
Example
Note the scopes are the same
now we use separate scopes
The text was updated successfully, but these errors were encountered: