Comments (2)
@phunanon Thanks for reporting, I will look in to this soon 👍
from re-pollsive.
@phunanon I am not able to reproduce. Can you provide the code that caused your error so we can try to debug?
When I tried with the latest re-frame, re-pollsive was working as expected. This is what I did:
lein new re-frame mypoll
- add repollsive to project.clj :depencencies
(defproject mypoll "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.758"
:exclusions [com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library
org.clojure/google-closure-library-third-party]]
[thheller/shadow-cljs "2.8.110"]
[reagent "0.10.0"]
[re-frame "0.12.0"]
[re-pollsive "0.1.0"]]
...
- Setup re-pollisve in project.clj
(ns mypoll.core
(:require
[reagent.core :as reagent]
[reagent.dom :as rdom]
[re-frame.core :as re-frame]
[mypoll.events :as events]
[mypoll.views :as views]
[mypoll.config :as config]
[mypoll.fx]
;; Add this (1 of 2)
[re-pollsive.core :as poll]
))
(defn dev-setup []
(when config/debug?
(println "dev mode")))
(defn ^:dev/after-load mount-root []
(re-frame/clear-subscription-cache!)
(let [root-el (.getElementById js/document "app")]
(rdom/unmount-component-at-node root-el)
(rdom/render [views/main-panel] root-el)))
(defn init []
(re-frame/dispatch-sync [::events/initialize-db])
;; And this (2 of 2)
(re-frame/dispatch-sync [::poll/init])
(dev-setup)
(mount-root))
- Add an event that will get called when the poller run
(ns mypoll.events
(:require
[re-frame.core :as re-frame]
[mypoll.db :as db]
))
(re-frame/reg-event-db
::initialize-db
(fn [_ _]
db/default-db))
(re-frame/reg-event-fx
::log
(fn [coeffects [event & values]]
{:logger (apply str values)}))
- Register a logger effect in a new file called mypoll.fx
(ns mypoll.fx
(:require [re-frame.core :as re-frame]))
(re-frame/reg-fx
:logger
(fn [value]
(println value)))
- Update mypoll.views to set the re-pollsive rules when the page is loaded
(ns mypoll.views
(:require
[re-frame.core :as re-frame]
[re-pollsive.core :as poll]
[mypoll.subs :as subs]
[mypoll.events :as events]
))
(defn main-panel []
(let []
(re-frame/dispatch
[::poll/set-rules
[{:interval 4
:event [::events/log "POLL (every 4 seconds)"]
:dispatch-event-on-start? true}
]])
(fn []
(let [name (re-frame/subscribe [::subs/name])]
[:div
[:h1 "Hello from " @name]
]))))
- start the application by running
lein dev
, then navigate to localhost:8280 then open the console and observe the logs which should see a printout every four seconds.
from re-pollsive.
Related Issues (2)
- Console Logging HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from re-pollsive.