0
votes

I have just started to develop apps in ClojureScript and I'm using Figwheel with Reagent and LightTable. Everything seems to be super interactive, I really love the idea of REPL and code reload but I cannot figure out how is it possible to transfer ratom from browser to REPL. For instance if I am developing tictactoe and it would be awesome if I will be able to transfer current board state to REPL just to play with it there (check some functions behaviour etc). Is it possible?

For example, ratom is defined in the tictactoe.core namespace as follows:

(defonce app-state (atom {:text "Welcom to the tictactoe!"
                          :board (new-board 3)}))

In browser console information about ratom is as shown:

#<Atom: {:text "Welcom to the tictactoe!", :board [[2 2 2] [1 1 2] [1 1 1]]}>

And when I'm trying to get information about the atom in the REPL in Terminal being in the tictactoe.core namespace:

tictactoe.core=> app-state
#<Atom: {:text "Welcom to the tictactoe!", :board [[0 0 0] [0 0 0] [0 0 0]]}>

What I am doing wrong? In the same REPL I am getting println the same as in the browser.

What should I do to get value of the ratom in the REPL?

2

2 Answers

1
votes

You can do this form REPL, if you have a ratom defined in a namespace (not locally to a component). Switch to a namespace, where a ratom is defined and reference it by its symbol name.

0
votes

Lighttable is creating internal browser tab and connecting REPL to that particular instance, so previously opened external browser tab is no longer synchronized with REPL. Thus the following command shows state of the ratom in the internal Lighttable tab.

tictactoe.core=> app-state

If connection to the external tab is required then one should follow View->Connections, click "Add Connection", "External Browser" and follow the instructions.