From 52a47f0f4c2e16115c424888900433611ee98956 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Wed, 7 Nov 2018 18:37:05 +0000 Subject: [PATCH] refactor(transducers-hdom): update auto-deref ctx behavior --- packages/transducers-hdom/src/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/transducers-hdom/src/index.ts b/packages/transducers-hdom/src/index.ts index 0171206852..c7a0ce975e 100644 --- a/packages/transducers-hdom/src/index.ts +++ b/packages/transducers-hdom/src/index.ts @@ -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 @@ -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) {