Fork me on GitHub
#reagent
<
2022-01-27
>
Richie01:01:57

Hey. I thought it would be a good idea to put my datascript db inside of my global app-state ratom. Basically (defonce app-db (r/atom {})) and then (defonce conn (r/cursor app-db [:ds-db])). And then finally I want to use posh so I tried (posh.reagent/posh! conn). I get an error Error: Assert failed: (atom? (:listeners (meta conn))). I can https://github.com/tonsky/datascript/blob/master/src/datascript/core.cljc#L447 that a datascript atom has :listeners meta. If I try adding meta to the cursor then I get another error. (vary-meta conn merge {:listeners (atom {})}) No protocol method IWithMeta.-with-meta defined for type reagent.ratom/RCursor: [object Object] Is this really a bad idea? How can I make this work? Thanks!

Error: Assert failed: (atom? (:listeners (meta conn)))
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljc:592:1)
    at Object.posh$plugin_base$set_conn_listener_BANG_ [as set_conn_listener_BANG_] (plugin_base.cljc:29:7)
    at eval (plugin_base.cljc:62:37)
    at eval (plugin_base.cljc:63:53)
    at Function.eval [as cljs$core$IFn$_invoke$arity$variadic] (plugin_base.cljc:63:53)
    at posh$plugin_base$posh_BANG_ (plugin_base.cljc:47:1)
    at Object.G__10337__1 (core.cljs:4345:12)
    at Object.G__10337 [as posh_BANG_] (core.cljs:4348:16)
    at eval (app.cljs:128:2)
    at eval (<anonymous>)