Fork me on GitHub
#re-frame
<
2018-06-05
>
Hendrik Poernama03:06:39

Question for other re-frame-ers, how would you interop with a js lib that exposes mutable objects and events?

Hendrik Poernama04:06:13

My current idea is to wire up event handlers that forces update, but there could be a better way?

Hendrik Poernama04:06:37

Initially I converted the data into immutable tree and store it app db. Nice to work with but I had to duplicate a lot of data.

Hendrik Poernama05:06:02

Hmm.. in my case, my view components are pure reagent. But my datasource is a chat client object that I can query for channels and messages. So I put this client object in app db. When a new message is received, the object just updates its internal structure and emits an event. My understanding is that this client object will not trigger a subscription reaction when a new message is received. If my view components query directly from this client object, I have to force update when an event is received.

Hendrik Poernama05:06:11

Also the fact that all of the client's API returns promise makes interop rather annoying.. But that's a different problem 🙂

mikethompson07:06:17

Yes. So the alternative would be to dispatch an event when new chat data arrives, and to store it in app-db

mikethompson07:06:33

In theory, arriving chat is just another kind of event, and so should be modeled via a dispatch

danielneal14:06:43

Is there any other reason that "Tracing is not enabled Please set re_frame.trace.trace_enabled_QMARK_ true in clojure-defines" might appear

danielneal14:06:51

I've set it to true in closure defines

danielcompton20:06:06

@danieleneal are you using re-natal? I think only the most recent version has support for closure defines

danielneal21:06:39

Ah thanks I'm using react native but with expo I guess I'll have to figure out how renatal does it and copy across

danielcompton22:06:25

If you do set a :main config, then you can see the closure defines in the :main file

danielcompton22:06:04

In our app I see:

var CLOSURE_UNCOMPILED_DEFINES = {"goog.DEBUG":true,"re_frame.trace.trace_enabled_QMARK_":true,"day8.re_frame.tracing.trace_enabled_QMARK_":true};
var CLOSURE_NO_DEPS = true;
if(typeof goog == "undefined") document.write('<script src="compiled_dev/parts/goog/base.js"></script>');
document.write('<script src="compiled_dev/parts/goog/deps.js"></script>');
document.write('<script src="compiled_dev/parts/cljs_deps.js"></script>');
document.write('<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>');
document.write('<script>goog.require("devtools.preload");</script>');
document.write('<script>goog.require("dirac.runtime.preload");</script>');
document.write('<script>goog.require("day8.re_frame_10x.preload");</script>');
document.write('<script>goog.require("figwheel.connect");</script>');
document.write('<script>goog.require("process.env");</script>');
document.write('<script>goog.require("day8.ourapp.main");</script>');

document.write("<script>figwheel.connect.start();</script>");