Skip to content
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

Add api to manually trigger events #5006

Closed
wants to merge 4 commits into from

Conversation

alpha0010
Copy link
Contributor

When, for example, implementing custom buttons in the top bar, one cannot use the event system from this library. This causes an awkward situation where text buttons route through the built in navigation system, but specialized buttons cannot.

The changes here add the ability to trigger (fake) events from javascript side, allowing all logic to route through the same path.

Navigation.events().notifyEvent('xxx_EventName_xxx', { event: 'data' });

@alpha0010
Copy link
Contributor Author

Devs, any feedback? Is there a different solution I should be using?

@stale
Copy link

stale bot commented Jul 20, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the 🏚 stale label Jul 20, 2019
@alpha0010
Copy link
Contributor Author

Still looking for feedback from devs.

@stale stale bot removed the 🏚 stale label Jul 22, 2019
@stale
Copy link

stale bot commented Sep 5, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the 🏚 stale label Sep 5, 2019
@alpha0010
Copy link
Contributor Author

Looking for feedback from devs.

@stale stale bot removed the 🏚 stale label Sep 11, 2019
@guyca guyca self-assigned this Sep 12, 2019
@guyca
Copy link
Collaborator

guyca commented Sep 12, 2019

Hey @alpha0010
I'm really sorry this PR slipped by me. We've had a similar system in v1 and botched it because we felt RNN shouldn't include a pub-sub implementation, and I still hold that position today. My main concerns are:

  1. Feature creep
  2. Potential performance issues - multiple components handling the event one after the other, potentially triggering more logic (setState, dispatch action etc) which could contribute to a busy JS thread.

I think implementing a pub-sub is less than an hours work and as it's not RNNs' main concern, it should not be part of the code base.

Perhaps we should document the best practices for this use case.

WDYT?

@alpha0010
Copy link
Contributor Author

I think triggering actions from a side menu or the top bar would be a relatively common use case. From the user (non-RNN dev) side, it feels odd to have an event system that handles only a bit of this. It makes more sense in the code (based on where native events come in).

Your reasons for avoiding this type of system in RNN make sense to me. However, it is still a situation closely related to navigation (from the issue tracker, appears others have had similar questions), so having best practices documentation would be great.

@stale
Copy link

stale bot commented Oct 28, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the 🏚 stale label Oct 28, 2019
@guyca
Copy link
Collaborator

guyca commented Oct 31, 2019

@alpha0010
#5612 adds support to update component props via mergeOptions. I believe this achieves something similar to what you had in mind.

@guyca guyca closed this Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants