I've used Javelin (https://github.com/hoplon/javelin) for this very purpose
(window width/height and resize) in
https://github.com/emnh/glsl-graph/blob/master/src/glsl_graph/core.cljs .

I use Stuart Sierra's component framework (
https://github.com/stuartsierra/component) to encapsulate the Javelin cells.

--
Eivind Magnus Hvidevold
Cell: +47 92 678 423

On Thu, Dec 10, 2015 at 9:24 PM, Adam Kowalski <[email protected]
> wrote:

> I would like to have a way to represent the current width and height of
> the window but I am not quite sure how to go about doing this.  For example
> if I have some element on the screen and I want it to be 50% of the window
> width, I would need to know every time the window is resized and update the
> width of my element with the new information.
>
> In a language like Elm there was a Signal abstraction, which represented
> values which change over time.  These signals could then be made to
> dispatch an action when they change. For example when window dimension
> signal had a new value, it would dispatch an action that would be picked up
> by my update function and would return a new model correctly representing
> the current state.
>
> In ClojureScript it seems like core.async is a good way to model something
> like this but I am not sure if this is the correct approach.  I would
> create a channel (ie: window dimension, mouse position, etc), and would
> then have an event listener for (resize, or mouse move) that would place
> the current values onto the channel.  Then I would need something to grab
> that value of the channel and mutate my model.
>
> Am I on the right track, or can I do something different/better?
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to