I'm trying to use Firebase with re-frame (no wrapper, just interop), and I have a problem with initializing Firebase. My idea was that I would use dispatch-sync to do so, but I am getting a (to me, at least) cryptic error message. "No protocol method IMap.-dissoc defined for type object: [object Object]". If I instead just call a function for initializing Firebase instead of going through dispatch-sync, I don't get an error.
Can you show the code?
For the event handler.
initializeApp takes a map as configuration for firebase, which I have removed
You need to use reg-fx and write your own event handler. In reg-event-fx you need to dispatch to your new event handler.
An event handler registered with
reg-event-fx has to return a map of effects (or
nil, I think).
initialize-firebase probably returns a
You want to move the
(initialize-firebase) into an effect handler, and return a proper effect map from that event handler on your pic.
Thank you so much, Sven and p-himik! 🙂
@snefrika You're mixing up event and effect handlers - those are different. Effects aren't dispatched, an effect map is simply returned from an event handler.
I obviously have some more reading to do. Thanks for putting me on the right course, p-himik.
@endrejoh Also note that
dispatch-sync might not do something that
dispatch wouldn't do in this case because
.initializeApp is async. You cannot wait in the code till Firebase is initialized.
All you can do is use the proper
Promise API and schedule more work after Firebase is initialized.
That makes sense. Thank you!1👍
We could probably assert that a
reg-event-fx fn returns map or
nil, and if not print a less cryptic error message. Maybe that would help those who hit this in the future ?