This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-30
Channels
- # adventofcode (18)
- # beginners (27)
- # boot (5)
- # cider (3)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (78)
- # clojure-austin (1)
- # clojure-brasil (2)
- # clojure-uk (1)
- # clojurescript (11)
- # css (1)
- # cursive (11)
- # data-science (6)
- # datascript (3)
- # datomic (3)
- # emacs (24)
- # graphql (1)
- # hoplon (2)
- # off-topic (1)
- # om (8)
- # onyx (1)
- # portkey (11)
- # re-frame (18)
- # ring (5)
- # ring-swagger (1)
- # shadow-cljs (1)
- # sql (5)
- # testing (1)
I'm working on a ClojureScript app that needs to react to messages that it receives on an AWS SQS queue. What's the best practice for an endless receive loop in re-frame? I also need to handle user input, so it can't be blocking.
I think that you will use something like this @jmglov
(doto (new SQSConnection "")
(.addHandler "on-messsage" (fn [m] (rf/dispatch [:new-sqs-message m]))))
you can make it with timers*, every 10 seconds, call it and get new messages and dispatch to re-frame. *`js/setTimeout`
@jmglov do you have to turn this SQS polling "on" and "off" depending on application state? Or does it have to happen for the entire life of the application?
If the former, then you'll have to create an "effect" to do the turning "on" and "off". This FAQ may help: https://github.com/Day8/re-frame/blob/master/docs/FAQs/PollADatabaseEvery60.md (although you may well want a variation on this for your usecase)
If the later, then your job is obviously simpler: just set up the timer when the app starts up, and leave it plugging away in the background, dispatching
when something interesting happens.