Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Allow AsyncMessageBroker to recieve data from subscribers ? #456

Open
superkerokero opened this issue May 31, 2020 · 1 comment · May be fixed by #457
Open

Allow AsyncMessageBroker to recieve data from subscribers ? #456

superkerokero opened this issue May 31, 2020 · 1 comment · May be fixed by #457

Comments

@superkerokero
Copy link

AsyncMessageBroker seems to be useful in cases where one may need to collect some data from subscribers.

Currently, you can await all subscribers to finish their jobs, then do something like this:

  • Publisher
await AsyncMessageBroker.Default.PublishAsync<TestMessage>(new TestMessage());
// Do something after
  • Subscriber
AsyncMessageBroker.Default.Subscribe<TestMessage>(_ =>
{
    return Observable.TimerFrame(10).AsUnitObservable();
}).AddTo(this);

But what I want to do is something like this:

  • Publisher
TestPayload[] payloads = await AsyncMessageBroker.Default.PublishAsync<TestPayload, TestMessage>(new TestMessage());
// Do something with awaited payloads
Debug.Log(payloads[0].Value);
  • Subscriber
AsyncMessageBroker.Default.Subscribe<TestMessage, TestPayload>(_ =>
{
    return Observable.TimerFrame(10).Select(_ => new TestPayload(Value=1000));
}).AddTo(this);
@superkerokero
Copy link
Author

I have just submitted a PR #457 to address this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant