-
Notifications
You must be signed in to change notification settings - Fork 27
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
Allow sending arbitrary notifications to a Component. #35
Allow sending arbitrary notifications to a Component. #35
Conversation
Adds the `reactor.component.broadcast(channel, **kwargs)` to send a notification to any `Component` subscribed to `channel`. The message is delivered in `Component.notification(channel, **kwargs)`.
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.
Hi @edelvalle
this looks good to me, I just tried it and it works.
I have a question : why did you add the _
on methods or arguments that are part of the "public" API ? They are intended to be used by the developers. My understanding is that in python those should be without the leading _
, keeping it for internal functionality that should not be used by developers. For instance: _template_name
or _subscriptions
.
I also have another use case that do not work with this version: I want to pass a callable to a sub-component so that it can be called and the value is sent to the parent component. I will post an issue for this one. On my version it works flawlessly (reactor 2 + jinja template). I use this for an autocomplete component for instance...
You are right, it is like kind of private because:
I see, in this case as I serialize the object state to the front-end, and serializing functions could be complicated. I would use this broadcast to talk to the parent component or any other component. The parent component could subscribe to a channel, where the child publishes updates.
So, should we merge this? |
I see. Ok makes sense. Let's continue like this.
That's indeed another solution for this problem.
Sure ! |
Ok, merging then. Now I will the the |
Adds the
reactor.component.broadcast(channel, **kwargs)
to send a notification to anyComponent
subscribed tochannel
. he message is delivered inComponent.notification(channel, **kwargs)
.