[ClojureScript] Re: Again re-frame and external javascript lib needing db state

2015-03-14 Thread Mike Thompson
On Sunday, March 15, 2015 at 4:30:35 AM UTC+11, Sven Richter wrote:
 Hi,
 
 I am still trying to integrate resumable.js. Got it mostly working so far.
 What I currenlty do is this. Define a global resumable object:
 
 (defonce resumable (js/Resumable. (clj-js {:target  /files/upload
 :headers {:X-CSRF-Token 
 (h/get-value glob_anti_forgery)}
 :query {:g-uuid #()}})))
 
 And here we see the problem already. If I want to provide additional query 
 parameters for the POST of resumable.js. You can do this with the :query key 
 value pair.
 
 I want to provide some parameter depending on user input, so this will change 
 after the construction of the resumable object. And the change will reside 
 inside the db, which I cannot access from the outside as far as I can tell, 
 but only via register-handler and register-sub.
 
 Did someone already solve a similar problem?
 
 The only thing that comes to my mind is global js state, which would be an 
 anti-pattern to re-frame I guess.
 
 Best Regards,
 Sven


I'm not familiar with js/Resumable, but the doc says query can be a function.   
In which case, make it a function which reads a value out of app-db  (which was 
put there via event handlers and user interaction)? 



--
Mike



-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Web UI DSL

2015-03-14 Thread Roberto Oliveros
Hello everyone!

For the past months I've been working on a project that I want to share with 
you. Its a DSL for describing web user interfaces based on Om and Bootstrap and 
you can reach it here:

https://github.com/roboli/full-control

Now a disclaimer, I'm not a computer scientist or clojure guru (but i'm working 
on it ;)...), nor I have experience open sourcing a project... Can you give an 
advice in how to proceed?

Also, the project in the repository works, but I know for sure it can be redone 
in a more efficient/elegant way to bring it to production. So if your 
interested please let me know.

I'll wait for your comments. Thanks.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] How to test XHTTP requests

2015-03-14 Thread Jonathon McKitrick
Is there a testing mode where the server runs and then the client tests against 
the server API calls?  I'm thinking of using the asynchronous testing ability 
of clojurescript.test, but I'm not sure how to make it work.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Re: ANN: re-frame v0.2.0 - an FRP MVC pattern for writing SPAs in Reagent. (Woah, so many LTAs!!)

2015-03-14 Thread Mike Thompson
On Saturday, March 14, 2015 at 2:52:45 PM UTC+11, AndyR wrote:
 On Friday, March 6, 2015 at 11:28:59 PM UTC-5, Mike Thompson wrote:
  re-frame is a pattern for writing SPAs, using Reagent. 
  https://github.com/Day8/re-frame
  [...]
  - pushes Reagent's FRP capabilities (via use of reaction)
 The magic thing about a reaction is that the computation it wraps will be 
 automatically re-run whenever 'its inputs' change, producing a new output 
 (return) value.
 
 What if I have a heavy computation in there and I don't actually display that 
 value right now in my app. Will it still be computed? Or is that something to 
 take special care of? So only lightweight computations in reactions?
 
 If that's the case, would it make sense to also create a lazy reaction that 
 only get's realized/computed when it's deref'ed?
 

reactions are only ever used in subscriptions, which are the query layer of 
re-frame.  They do not create new data. Instead, their job is to reactively 
supply views (queries) across existing data (in app-db, the single source 
of truth ratom). 

The CPU intensive calculation of new values happen in event handlers, using 
this sort of a pattern: 
https://github.com/Day8/re-frame/wiki/Solve-the-CPU-hog-problem

Clarification:  sometimes a query delivers derived data  (a kind of 
materialised view) which DOES involves CPU intensive work.  For example, a 
query might involve sorting a collection of items and finding the top 20 items 
(so they can be displayed in the view). That's something that would happen 
inside a reaction. But in this case there's no new data being created (the 
collection of items doesn't change), just a derived version of that data is 
being created for view purposes. 

Regarding lazy calculation: you can certainly do that. You'd wait for the right 
trigger to perform the calculation - but the calculation would happen in an 
event handler.  Only event handlers can update app-db (providing new data to 
the application). 

--
Mike




--
Mike



-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Again re-frame and external javascript lib needing db state

2015-03-14 Thread Sven Richter
Hi,

I am still trying to integrate resumable.js. Got it mostly working so far.
What I currenlty do is this. Define a global resumable object:

(defonce resumable (js/Resumable. (clj-js {:target  /files/upload
:headers {:X-CSRF-Token 
(h/get-value glob_anti_forgery)}
:query {:g-uuid #()}})))

And here we see the problem already. If I want to provide additional query 
parameters for the POST of resumable.js. You can do this with the :query key 
value pair.

I want to provide some parameter depending on user input, so this will change 
after the construction of the resumable object. And the change will reside 
inside the db, which I cannot access from the outside as far as I can tell, but 
only via register-handler and register-sub.

Did someone already solve a similar problem?

The only thing that comes to my mind is global js state, which would be an 
anti-pattern to re-frame I guess.

Best Regards,
Sven

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.