-
Notifications
You must be signed in to change notification settings - Fork 68
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 users provide code to handle context-level events #126
Comments
Hey @halfninety, this seems like it could be useful. Do you have any particular use cases in mind? As for how it could be done, it may make sense to provide facets similar to myComponent: {
create: //...,
contextReady: 'doSomething'
} Or, maybe it makes sense to namespace them: myComponent: {
create: //...,
context: {
ready: 'doSomething'
}
} Any thoughts about those options? |
Very nice. I like the second option. I don't have any use case in mind yet, just thought this could be useful. |
Cool, thanks for the feedback. I kinda like the second one as well. I'd like to see if @unscriptable and @scothis have any thoughts. Maybe they can think of some interesting use cases, or ideas for the DSL/API. |
I think I need some use cases before I can comment coherently on this. :) |
What are the use cases you had in mind when adding context-level events? How are these events used now? |
@halfninety Typically, they are used by plugins to do setup or teardown. For example, it's quite common for a facet that provides some sort of connection functionality (like I'm just not sure yet what things user-level code might do with them. One thought is that you might use |
It's similar in spirit to the
init
,ready
anddestroy
built-in facets. The majority of users don't write plugins, if they can't write user code to handle context-level events, these events aren't very useful.As to how to do it, I don't know. Maybe through new options to the wire factory? But then you can't handle events of the root context. Maybe an additional parameter to the global
wire()
function.The same mechanism may also be used to allow users to also handle component events in the context level, I mean those general lifecycle listeners, in user code.
The text was updated successfully, but these errors were encountered: