Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for adding JS dependencies. #68

Open
mattdeboard opened this issue Sep 19, 2014 · 1 comment
Open

Add support for adding JS dependencies. #68

mattdeboard opened this issue Sep 19, 2014 · 1 comment

Comments

@mattdeboard
Copy link

When using a browser-connected REPL for Om, I'd love to be able to invoke Om functions to investigate their outputs and so forth. However this would require having the React object from react.js avaliable in the page. The default HTML generated by send-repl-index however is pretty minimal (by design).

I can think of a few ways to accomplish this:

  • have some kind of additional config/hook in profiles.clj to specify additional URLs (http or file system) for libs to include;
  • read from :preamble and add the paths specified there as <script> tags;
  • same as above but just add those libs to the client.js
@mattdeboard
Copy link
Author

I "hacked in" a manner of doing this with this here:

(extend-type js/HTMLCollection
  ISeqable
  (-seq [array] (array-seq array 0)))

;; Bootstrap the DOM in a browser-connected REPL so ReactJS is available
(defn repl-react-js
  "Add ReactJS to browser-connected REPl session."
  [] (let [head (first (. js/document (getElementsByTagName "head")))
           script (. js/document (createElement "script"))]
       (set! (.-type script) "text/javascript")
       (set! (.-src script) "http://fb.me/react-0.11.2.js")
       (. head (appendChild script))))

I'm sure it's super-naive but it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant