Fork me on GitHub
#re-frame
<
2021-04-18
>
ej09:04:47

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.

p-himik09:04:31

Can you show the code?

p-himik09:04:38

For the event handler.

ej09:04:24

initializeApp takes a map as configuration for firebase, which I have removed

Sven Neirynck09:04:25

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.

p-himik09:04:07

An event handler registered with reg-event-fx has to return a map of effects (or nil, I think). Whereas initialize-firebase probably returns a Promise. You want to move the (initialize-firebase) into an effect handler, and return a proper effect map from that event handler on your pic.

ej09:04:53

Thank you so much, Sven and p-himik! 🙂

p-himik09:04:56

@U01NM475LKB 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.

ej09:04:02

I obviously have some more reading to do. Thanks for putting me on the right course, p-himik.

p-himik09:04:04

@U01FJKR2SEA 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.

p-himik09:04:35

All you can do is use the proper Promise API and schedule more work after Firebase is initialized.

ej09:04:31

That makes sense. Thank you!

👍 3
superstructor22:04:49

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 ?

👍 7