Fork me on GitHub
#re-frame
<
2021-11-06
>
aqua08:11:26

Hi, I'm following the tutorial here https://day8.github.io/re-frame/dominoes-live/#the-view-functions and noticed that although most live code snippets seem to work, at the chapter The View Functions the [clock] snippet breaks on first load: "Execution error. ERROR: TypeError: Cannot read properties of null (reading 'toTimeString')". This doesn't seem to happen for any other snippets, even similar ones like [color-input] and [url]. When I make a trivial change to the code for defn clock (like adding some whitespace), the snippets rerender and the clock is correctly displayed below the error. Just thought I'd post this here, wasn't sure whether a bug report on the repo would be appropriate for docs like this.

aqua08:11:58

Maybe replacing -> by some-> in defn clock fixes it? It would prevent the error at least I think, but not sure whether it will rerender by itself after that

aqua08:11:46

I cloned the repo to try that out, but klipse doesn't seem to work when I run the docs locally (404 for js files)

lispers-anonymous17:11:07

The time subscription is returning nil the first time. The db is probably not being initialized (via the :initialize event) before that clock component is rendered. Using some-> would avoid the error thrown in the component, but it doesn't solve the underlying problem.

lispers-anonymous17:11:58

The problem in the example is that the db is not initialized until after the clock component above is rendered. https://day8.github.io/re-frame/dominoes-live/#kick-starting-the-app If the call to (rf/dispatch-sync [:initialize]) was done before the clock component you wouldn't see this problem. That may be a suggestion to make in a bug report.