com.raquo.laminar.inserters
Members list
Type members
Classlikes
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ChildInserter.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ChildTextInserter.type
Note: this is a low level inserter. It is the fastest one in certain cases, but due to its rather imperative API, its usefulness is very limited.
Note: this is a low level inserter. It is the fastest one in certain cases, but due to its rather imperative API, its usefulness is very limited.
It's good for simple operations on voluminous data, like prepending new log items to a big list, but not much else.
Consider using children <-- observable.split(...)
instead, it has great performance and is much more convenient.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ChildrenInserter.type
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
CollectionCommand.type
Inserter is a modifier that lets you insert child node(s) on mount. When used with onMountInsert, it "immediately" reserves an insertion spot and then on every mount it inserts the node(s) into the same spot.
Inserter is a modifier that lets you insert child node(s) on mount. When used with onMountInsert, it "immediately" reserves an insertion spot and then on every mount it inserts the node(s) into the same spot.
Note: As a Modifier this is not idempotent, but overall it behaves as you would expect. See docs for more details.
Note: If you DO provide initialContext, its parentNode MUST always be the same element
that you apply this Modifier to.
Attributes
- Supertypes
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
- Self type
InsertContext represents the state of the DOM inside an inserter block like child <-- ...
, children <-- ...
, child.text <-- ...
, etc. The data stored in this context is used by Laminar to efficiently update the DOM, to detect (and recover from) external changes to the DOM, and for other related tasks.
InsertContext represents the state of the DOM inside an inserter block like child <-- ...
, children <-- ...
, child.text <-- ...
, etc. The data stored in this context is used by Laminar to efficiently update the DOM, to detect (and recover from) external changes to the DOM, and for other related tasks.
InsertContext is a mutable data structure that is created once for each inserter, and the inserter updates it as it processes new data. However, in case of onMountInsert
, only one context is created, and is then reused for all inserters created inside onMountInsert
. This allows for intuitive preservation of DOM state if the element is unmounted and mounted again (for example, onMountInsert(child <-- stream)
will keep the last emitted child in the DOM even if the element is unmounted and re-mounted).
#Note: The params that describe extraNodes
below can get out of sync with the real DOM.
This can happen if an child element is removed from the DOM – either externally, or more likely because it was moved from this inserter into another one, and the addition to the other inserter was processed before the removal from this inserter is processed (the order of these operations depends on the propagation order of the observables feeding these two inserters). The Inserter code must account for this and not fail in such cases, and must correct the values accordingly on the next observable update.
#Note: The params that describe extraNodes
below must be kept consistent manually (#Perf)
Inserter "steals" an element from this one just before the
observable source of this inserter provides a new list of
children (with the stolen element removed from the list).
Value parameters
- extraNodeCount
-
- Number of child nodes in addition to the sentinel node. Warning: can get out of sync with the real DOM!
- extraNodesMap
-
- Map of child nodes in addition to the sentinel node, for more efficient search Warning: can get out of sync with the real DOM!
- sentinelNode
-
- A special invisible comment node that tells Laminar where to insert the dynamic children, and where to expect previously inserted dynamic children.
- strictMode
-
- If true, Laminar guarantees that it will keep a dedicated sentinel node instead of using the extra node (content node) for that purpose. This is needed in order to allow users to move an element from one inserter to another, or to externally remove some of the elements previously added by an inserter. child.text does not need any of that, so for performance it does not use strict mode, it replaces the sentinel comment node with the subsequent text nodes. Inserters should be able to safely switch to their preferred mode when receiving context left by the previous inserter in onMountBind.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
InsertContext.type
Inserter is a class that can insert child nodes into InsertContext.
Inserter is a class that can insert child nodes into InsertContext.
This is needed in onMountInsert
, or when rendering dynamic children with child <-- ...
, children <-- ...
, etc.
If you don't have a InsertContext, you can render the Inserter just by calling its apply
method. It will work the same way as rendering any other child node, static or dynamic, would.
So, you can use Inserter essentially as (an implicit-powered) sypertype of regular laminar elements and dynamic inserters like children <-- ...
. We use it this way in onMountInsert
, for example.
Attributes
- Supertypes
- Known subtypes
-
class DynamicInsertertrait StaticInserterclass StaticChildInserterclass StaticChildrenInserterclass StaticTextInserter
#TODO This API is experimental, and is likely to change in the future.
#TODO This API is experimental, and is likely to change in the future.
We currently use it only for slotting elements into web components, but will likely use it more broadly later.
NOTE: Currently hooks do not run on some text nodes. They are also not run on some sentinel comment nodes, because only element nodes are slottable. So, this is fine for slotting purposes, but that's the kind of thing that will need a more principled contract if this API is to be used more widely.
WARNING: Your hooks should not throw! Any thrown errors will be sent to Airstream unhandled errors.
Value parameters
- _onWillInsertNode
-
Called before the child will be inserted into the parent. - NOTE: this includes moving the child from one position to another in the same parent. - NOTE: this can be called when no action is necessary (i.e. child is already at the target location)
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Inserter for a single static node
Inserter for a single static node
Attributes
- Companion
- object
- Supertypes
-
trait Hookable[StaticChildInserter]trait StaticInsertertrait Inserterclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
StaticChildInserter.type
Inserter for multiple static nodes. This can also insert a single nodes, just a bit less efficiently than SingleStaticInserter.
Inserter for multiple static nodes. This can also insert a single nodes, just a bit less efficiently than SingleStaticInserter.
Attributes
- Companion
- object
- Supertypes
-
trait Hookable[StaticChildrenInserter]trait StaticInsertertrait Inserterclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Attributes
- Supertypes
- Known subtypes
Inserter for a single static node
Inserter for a single static node
Attributes
- Supertypes