new (require("nmodule/webEditors/rc/wb/table/model/source/ContainerComponentSource"))(obj)
API Status: Development
This ComponentSource
implementation takes a Component
container and an
optional array of Types to filter against. For instance, you'd pass in
a UserService
and retrieve all the User
slots. It will attach handlers
to fire added
and removed
events when matching Components are added
or removed from the container, or changed
events when child components
have their properties change.
Since Baja event handlers will be attached to the input component, ensure
that you call destroy()
when done with the ComponentSource
to detach
these handlers and avoid memory leaks.
By default, hidden slots will always be excluded. To include hidden slots,
pass a custom filter function.
Extends:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
obj |
Object | baja.Component | params object, or the Properties
|
Methods
-
addComponents(comps [, names])
-
Add the (unmounted) components to the container. If names are also given,
those names will be used; otherwise default slot names will be generated.If the current container component is not subscribed, an
added
tinyevent
will be emitted by this function; otherwiseadded
will be emitted by
the subscriber attached in theContainerComponentSource
constructor.Parameters:
Name Type Argument Description comps
Array.<baja.Component> names
Array.<String> <optional>
Returns:
- Type
- Promise
-
destroy()
-
Clean up Baja event handlers attached to the container Component.
-
getComponents()
-
Gets an array of all matching child Components of the container.
Returns:
- Type
- Array.<baja.Component>
-
getContainer()
-
The container object passed to the constructor.
Returns:
- Type
- Object
-
handleAdded(values)
-
Emits an
added
event when a new property is added.Parameters:
Name Type Description values
Array.<baja.Component> -
handleChanged(comp, prop)
-
Emits a
changed
event when a property is changed or renamed.Parameters:
Name Type Description comp
baja.Component prop
baja.Property -
handleRemoved(values)
-
Emits a
removed
event when a property is removed from the source.Parameters:
Name Type Description values
Array.<baja.Component> -
makeAttachable(comp)
-
Create a new
Attachable
instance for the given component, that will
hook up to the various 'handle*' methods. The default implementations
of these will emit the appropriate event from this instance.Parameters:
Name Type Description comp
baja.Component a
Component
to be attached to.Returns:
-
removeComponents(comps)
-
Remove the given components from the container. If any of the components
are not currently children of the current container, no action will be
taken for that component.If the current container component is not subscribed, a
removed
tinyevent
will be emitted by this function; otherwiseremoved
will be emitted by
the subscriber attached in theContainerComponentSource
constructor.Parameters:
Name Type Description comps
Array.<baja.Component> Returns:
- Type
- Promise