我有一个重新设计的项目,并且我的事件、subs 和 db cljs 文件已被填充。我在我的项目中使用这三个并且效果很好。但是我创建了一个测试文件,并在其中调用了 subscribe 和 dispatch ,如下所示:
(deftest category-filter-test
(dispatch [:add-filter "cat"])
(is (= @(subscribe [:filters]) ["cat"]))
)
那是行不通的。我明白了
#object[Error Error: No protocol method IDeref.-deref defined for type undefined: ]
另一方面,如果我尝试在 shadow-cljs repl 中运行 subscribe,我会收到以下错误:
------ WARNING - :undeclared-ns ------------------------------------------------
Resource: :1:2
No such namespace: user, could not locate user.cljs, user.cljc, or JavaScript source providing "user"
--------------------------------------------------------------------------------
------ WARNING - :undeclared-var -----------------------------------------------
Resource: :1:2
Use of undeclared Var user/start
--------------------------------------------------------------------------------
ReferenceError: user is not defined
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js), <anonymous>:1:1)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:758:16)
at eval (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:767:44)
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:167:108)
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:766:46)
at shadow$cljs$devtools$client$browser$handle_message (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.browser.js:844:37)
at eval (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:307:151)
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:289:90)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (http://localhost:3689/js/workspaces/cljs-runtime/shadow.cljs.devtools.client.env.js:310:40)
如何解决这两个错误?