Module: nmodule/webEditors/rc/wb/table/model/source/ContainerComponentSource


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 Component
container itself if no other params needed

Properties
Name Type Argument Description
container baja.Component

the Component container

filter Array.<(Type|String)> | function <optional>

if given, only child
components matching these Types will be returned from getComponents or
cause events to be fired. This can also be a function that takes a Slot as
its first argument and the Slot's value as its second, and should return true
or false to include or exclude the value.

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; otherwise added will be emitted by
the subscriber attached in the ContainerComponentSource constructor.

Parameters:
Name Type Argument Description
comps Array.<baja.Component>
names Array.<String> <optional>
Overrides:
Returns:
Type
Promise

destroy()

Clean up Baja event handlers attached to the container Component.

Overrides:

getComponents()

Gets an array of all matching child Components of the container.

Overrides:
Returns:
Type
Array.<baja.Component>

getContainer()

The container object passed to the constructor.

Inherited From:
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:
Type
module:nmodule/webEditors/rc/fe/baja/util/Attachable

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; otherwise removed will be emitted by
the subscriber attached in the ContainerComponentSource constructor.

Parameters:
Name Type Description
comps Array.<baja.Component>
Overrides:
Returns:
Type
Promise