ingesolvoll / re-statecharts

re-frame integration for clj-statecharts
Eclipse Public License 2.0
21 stars 1 forks source link

Error using with-fsm macro. Use of undeclared state variable #5

Open nyemiks opened 5 months ago

nyemiks commented 5 months ago

I am unable to run the default example from the documentation

(defn form [] (rs/with-fsm [state global-image-fsm] (r/with-let [ text (r/atom "") update-text #(reset! text (-> % .-target .-value)) ] [:div [:input { :type :text :on-change #(update-text %) :on-focus #(re-frame/dispatch [::edit-started :validation-open]) :on-blur #(re-frame/dispatch [::edit-ended :validation-open]) } ] ] ) ) )

I get the below error trace

This is a pseudo terminal, only used for hosting the Jack-in REPL process. It takes no input. Pressing ctrl+c with this terminal focused, killing this terminal, or closing/reloading the VS Code window will all stop/kill the Jack-in REPL process.

⚡️ Starting the REPL ⚡️ using the below command line: pushd c:\Users\nyemi\Documents\react\myproject2\fetchimagefsm4 & npx.cmd shadow-cljs -d cider/cider-nrepl:0.47.1 watch :app & popd shadow-cljs - config: c:\Users\nyemi\Documents\react\myproject2\fetchimagefsm4\shadow-cljs.edn shadow-cljs - socket connect failed, server process dead? shadow-cljs - HTTP server available at http://localhost:8280 shadow-cljs - HTTP server available at http://localhost:8290 shadow-cljs - server version: 2.26.2 running at http://localhost:9630 shadow-cljs - nREPL server started on port 8777 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. [:app] Build completed. (308 files, 2 compiled, 5 warnings, 113.26s)

------ WARNING #1 - :undeclared-var -------------------------------------------- File: C:\Users\nyemi\Documents\react\myproject2\fetchimagefsm4\src\fetchimagefsm4\views.cljs:190:4

187 | 188 | 189 | (defn form [] 190 | (rs/with-fsm [state global-image-fsm] ----------^--------------------------------------------------------------------- Use of undeclared Var re-statecharts.core/with-fsm

191 | (r/with-let [ 192 | text (r/atom "") 193 | update-text #(reset! text (-> % .-target .-value)) 194 | ]

------ WARNING #2 - :undeclared-var -------------------------------------------- File: C:\Users\nyemi\Documents\react\myproject2\fetchimagefsm4\src\fetchimagefsm4\views.cljs:190:17

187 | 188 | 189 | (defn form [] 190 | (rs/with-fsm [state global-image-fsm] -----------------------^-------------------------------------------------------- Use of undeclared Var fetchimagefsm4.views/state

191 | (r/with-let [ 192 | text (r/atom "") 193 | update-text #(reset! text (-> % .-target .-value)) 194 | ]

------ WARNING #3 - :infer-warning --------------------------------------------- File: C:\Users\nyemi\Documents\react\myproject2\fetchimagefsm4\src\fetchimagefsm4\views.cljs:191:5

188 | 189 | (defn form [] 190 | (rs/with-fsm [state global-image-fsm] 191 | (r/with-let [ -----------^-------------------------------------------------------------------- Cannot infer target type in expression (. with-let23337 -generation)

192 | text (r/atom "") 193 | update-text #(reset! text (-> % .-target .-value)) 194 | ] 195 | [:div

------ WARNING #1 - :protocol-invalid-method ----------------------------------- Resource: re_statecharts/core.cljc:106:1

103 | (when-let [new-db (transition db machine opts fsm-event data more-data)] 104 | {:db new-db}))) 105 | 106 | (deftype Scheduler [fsm-id ids clock open?] -------^------------------------------------------------------------------------ Bad method signature in protocol implementation, delayed/IScheduler schedule does not declare arity 3

107 | delayed/IScheduler 108 | (schedule [_ event delay] 109 | (let [id (clock/setTimeout clock #(f/dispatch (if open? 110 | event

------ WARNING #2 - :protocol-invalid-method ----------------------------------- Resource: re_statecharts/core.cljc:106:1

103 | (when-let [new-db (transition db machine opts fsm-event data more-data)] 104 | {:db new-db}))) 105 | 106 | (deftype Scheduler [fsm-id ids clock open?] -------^------------------------------------------------------------------------ Bad method signature in protocol implementation, delayed/IScheduler unschedule does not declare arity 2

107 | delayed/IScheduler 108 | (schedule [_ event delay] 109 | (let [id (clock/setTimeout clock #(f/dispatch (if open? 110 | event

There is a problem with the with-fsm macro. I have no idea why this error happens. I was able to use the low level api to get it to work but in my own opinion the with-fsm macro looks more high level.

What is missing in the above code ?