Created
August 31, 2016 13:00
-
-
Save kitsonk/22ed00af05d0a396bb920cd2f5cb4176 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createApp from 'dojo-app/createApp'; | |
import createStatefulChildrenMixin from 'dojo-widgets/mixins/createStatefulChildrenMixin'; | |
import createParentListMixin from 'dojo-widgets/mixins/createParentListMixin'; | |
import createCachedRenderMixin from 'dojo-widgets/mixins/createCachedRenderMixin'; | |
import createRenderableChildrenMixin from 'dojo-widgets/mixins/createRenderableChildrenMixin'; | |
import createWidget from 'dojo-widgets/createWidget'; | |
import createMemoryStore from 'dojo-widgets/util/createMemoryStore'; | |
const widgetStore = createMemoryStore({ | |
data: [ | |
{ id: 'parent', children: [] } | |
] | |
}); | |
const app = createApp({ | |
defaultWidgetStore: widgetStore | |
}); | |
const createParentWidget = createCachedRenderMixin | |
.mixin(createParentListMixin) | |
.mixin({ | |
mixin: createStatefulChildrenMixin, | |
initialize(instance) { | |
instance | |
.createChild(createWidget, { state: { label: 'child widget' } }) | |
.catch((err) => { | |
console.error(err); | |
}); | |
} | |
}) | |
.mixin(createRenderableChildrenMixin); | |
app.loadDefinition({ | |
widgets: [ | |
{ id: 'parent', factory: createParentWidget } | |
] | |
}); | |
app.realize(document.body) | |
.catch((err) => { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment