ej 2021-04-18T09:25:47.194700Z

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-himik 2021-04-18T09:29:31.195600Z

Can you show the code?

p-himik 2021-04-18T09:29:38.195800Z

For the event handler.

ej 2021-04-18T09:30:24.196Z

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

Sven Neirynck 2021-04-18T09:36:25.196500Z

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-himik 2021-04-18T09:37:07.196700Z

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.

ej 2021-04-18T09:37:53.196900Z

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

p-himik 2021-04-18T09:37:56.197100Z

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

ej 2021-04-18T09:39:02.197300Z

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

p-himik 2021-04-18T09:39:04.197500Z

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

p-himik 2021-04-18T09:39:35.197700Z

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

ej 2021-04-18T09:41:31.197900Z

That makes sense. Thank you!

superstructor 2021-04-18T22:12:49.198300Z

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 ?