Skip to content

Instantly share code, notes, and snippets.

@darthdeus
Last active January 3, 2016 04:49
Show Gist options
  • Save darthdeus/8411616 to your computer and use it in GitHub Desktop.
Save darthdeus/8411616 to your computer and use it in GitHub Desktop.
(ns lt.tutorial
(:require [lt.object :as object]
[lt.objs.tabs :as tabs]
[lt.objs.statusbar :as statusbar]
[lt.objs.notifos :as notifos]
[lt.util.js :as util])
(:require-macros [lt.macros :refer [behavior defui]]))
(defui work-button [this]
[:input {:type "submit" :value "Do work"}]
:click #(object/raise this :clicked %))
(object/object* ::worker
:name "A hard worker"
:behaviors [::work-on-click ::on-close-destroy]
:init (fn [this] (work-button this)))
(behavior ::work-on-click
:triggers #{:clicked}
:reaction (fn [this]
(notifos/working "Doing some heavy lifting!")
(util/wait 10000 #(statusbar/loader-set 0))))
(behavior ::on-close-destroy
:triggers #{:close}
:reaction (fn [this]
(when-let [ts (:lt.objs.tabs/tabset @this)]
(when (= (count (:objs @ts)) 1)
(tabs/rem-tabset ts)))
(object/raise this :destroy)))
(let [worker (object/create ::worker)]
(tabs/add! worker)
(tabs/active! worker))
@AleksLitynski
Copy link

This is causing: TypeError: Cannot call method 'call' of undefined

Googling isn't helping and the lightable freenode doesn't seem very active.

I know its not specific to your code, but do you have any idea what it's about?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment