On Tuesday, April 21, 2015 at 4:52:05 AM UTC+10, Colin Yates wrote:
> Hi,
>
> This is somewhat reframe specific, but how do people handle default-values
> that can change? My specific use-case is that I have a tree which can be
> expanded and collapsed. By default the tree should be expanded to a certain
> level, however, as soon as the user manually expands or collapses a node they
> should no longer follow the default. The data the tree is displaying can
> change, meaning the defaults can change over time.
>
> I can't simply define the defaults on startup because the defaults will
> change over time.
>
> It can't be a subscription because the values need to be available in the
> handler.
>
> My current thinking is that the app-db state has a 'follow-defaults?' which
> is true by default but is set to false when the user explicitly changes the
> state (e.g. by expanding or collapsing). When the underlying hierarchy
> changes from the server, propagate that change to all of the parts of the
> app-state that are interested.
>
> To be explicit, imagine I have the following template for tree:
> {:expanded-ids [] :follow-defaults? true}. There are 6 instances of this
> template in the app-db (i.e. 6 distinct UI trees). When the server informs
> the client that the source-data has changed it then updates each instance
> where follow-defaults?.
>
> I understand the rationale as to why subscriptions can't be in the handlers
> but a subscription which switches on follow-defaults? seems ideal.
>
> Maybe I could hack a UI-less component which reacts to that subscription
> change by directly updating the underlying db...
>
> What would you all do?
Hi Colin,
I'm not sure I'm clear on the problem. Here's my attempt to explain back ...
You have some setting (data) in your app (tree display state) which can be:
1. in a server-supplied state (you call this "default" state?)
2. optionally, in user-supplied state (if present, overrides 1).
Over time, new versions of 1. arrive. If 2. exists, it always overrides 1.
Have I understood?
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.