Packages

p

com.raquo.laminar

inserters

package inserters

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. sealed trait CollectionCommand[+Item] extends AnyRef
  2. class DynamicInserter extends Inserter with Hookable[DynamicInserter]

    Inserter is a modifier that lets you insert child node(s) on mount.

    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.

  3. trait Hookable[+Self <: Inserter] extends AnyRef
  4. final class InsertContext extends AnyRef

    InsertContext represents the state of the DOM inside an inserter block like child <-- ..., children <-- ..., child.text <-- ..., etc.

    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).

  5. sealed trait Inserter extends Modifier[Base]

    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.

  6. class InserterHooks extends AnyRef

    #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.

  7. class StaticChildInserter extends StaticInserter with Hookable[StaticChildInserter]

    Inserter for a single static node

  8. class StaticChildrenInserter extends StaticInserter with Hookable[StaticChildrenInserter]

    Inserter for multiple static nodes.

    Inserter for multiple static nodes. This can also insert a single nodes, just a bit less efficiently than SingleStaticInserter.

  9. trait StaticInserter extends Inserter
  10. class StaticTextInserter extends StaticInserter

    Inserter for a single static node

Value Members

  1. object ChildInserter
  2. object ChildTextInserter
  3. object ChildrenCommandInserter

    Note: this is a low level inserter.

    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.

  4. object ChildrenInserter
  5. object CollectionCommand
  6. object InsertContext
  7. object StaticChildInserter
  8. object StaticChildrenInserter

Ungrouped