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

on-value callback for on-value subscriptions #2

Closed
wants to merge 1 commit into from

Conversation

pbzdyl
Copy link
Contributor

@pbzdyl pbzdyl commented Sep 24, 2017

I found it useful to have ability to specify my own on-value callback in on-value subscriptions so I can plug in my event handler to sync some Firebase path with app-db. This way I can have an easy access to some data in other event handlers that otherwise don't have access to data from subscriptions directly.

@deg
Copy link
Owner

deg commented Sep 25, 2017

I don't quite see why this is needed.

Can you give me an example where this works better than just subscribing to the :on-value from somewhere and dispatching the event from there?

@pbzdyl
Copy link
Contributor Author

pbzdyl commented Sep 25, 2017

I have one example in my sample app.

How would I dispatch an event whenever value in the subscription is changed?

@deg
Copy link
Owner

deg commented Sep 25, 2017

Ah, now I understand what you are saying. Basically, this is a special-case workaround of a larger problem of how to get the result of a subscription in an event.

It looks like this has been actively discussed for the past few months. See:
day8/re-frame#255. The discussion is summarized nicely in https://github.com/Day8/re-frame/blob/master/docs/FAQs/UseASubscriptionInAnEventHandler.md and the short answer is to use inject-sub from re-frame-utils.

While your solution is elegant, it will introduce syntax into re-frame-firebase that may need to be replaced by a more general solution soon. I'm not comfortable doing this now.

I don't yet have enough experience using this library, and I'd like to keep it lean, until I understand more about how we use it.

But, we can leave this PR open. I'm happy to revisit if you find an example that needs this and can't be solved in the more general way.

@pbzdyl
Copy link
Contributor Author

pbzdyl commented Sep 25, 2017

I have migrated to the solution with injecting subscription and it works thus I am closing this PR. Thank you!

@pbzdyl pbzdyl closed this Sep 25, 2017
@pbzdyl pbzdyl deleted the on-value branch September 25, 2017 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants