Skip to content

Commit

Permalink
refactor(transducers-hdom): update auto-deref ctx behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 7, 2018
1 parent 3016116 commit 52a47f0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/transducers-hdom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ import { scan } from "@thi.ng/transducers/xform/scan";
* By default, incoming values are first normalized using hdom's
* `normalizeTree()` function and a copy of the given (optional) `ctx`
* object is provided to all embedded component functions in the tree.
* Any context keys with values implementing the thi.ng/api `IDeref`
* interface, will be automatically deref'd prior to tree normalization.
* If the `autoDerefKeys` option is given, attempts to auto-expand/deref
* the given keys in the user supplied context object (`ctx` option)
* prior to *each* tree normalization. All of these values should
* implement the thi.ng/api `IDeref` interface (e.g. atoms, cursors,
* views, rstreams etc.). This feature can be used to define dynamic
* contexts linked to the main app state, e.g. using derived views
* provided by thi.ng/atom.
*
* If the `hydrate` option is given, the first received tree is only
* used to inject event listeners and initialize components with
Expand Down Expand Up @@ -43,7 +48,7 @@ export const updateDOM =
reducer(
() => [],
(prev, curr) => {
_opts.ctx = derefContext(opts.ctx);
_opts.ctx = derefContext(opts.ctx, _opts.autoDerefKeys);
curr = impl.normalizeTree(_opts, curr);
if (curr != null) {
if (_opts.hydrate) {
Expand Down

0 comments on commit 52a47f0

Please sign in to comment.