Skip to content

Commit

Permalink
Add lazy loading and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mortalapeman committed Apr 26, 2014
1 parent d9240fb commit 290bbe5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -22,6 +22,11 @@ The default configuration for Tern is the browser environment `(:lt.plugins.tern
(:lt.plugins.tern/plugin :node true)]}
:- {:tern.config [:lt.plugins.tern/libs]}}

To setup a configuration for RequireJS:

{:+ {:tern.config [(:lt.plugins.tern/plugin :requirejs {:baseURL "/home/path/to/project/dir"})
:lt.plugins.tern/lazy-loading]}}

Arguments to `:lt.plugins.tern/libs` can be:

1. One or many built in libs: `:ecma5 :browser :jquery :underscore`
Expand Down
9 changes: 8 additions & 1 deletion src/lt/plugins/tern.cljs
Expand Up @@ -325,7 +325,9 @@
(.on worker "message" msg)
(.on worker "disconnect" dis)
(.on worker "exit" dis)
(current-ws-jsfiles init-cb)
(if (object/raise-reduce config :lazy-loading+ false)
(init-cb nil [])
(current-ws-jsfiles init-cb))
(object/merge! this {::worker worker})))))

(behavior ::error
Expand Down Expand Up @@ -432,6 +434,11 @@
(object/update! this [:options :plugins] conj value)))))


(behavior ::lazy-loading
:triggers #{:lazy-loading+}
:reaction (fn [this _ _]
true))

(object/object* ::tern.config
:tags #{:tern.config}
:options {:libs #{}
Expand Down

0 comments on commit 290bbe5

Please sign in to comment.