UNPKG

@motorcycle/mostly-dom

Version:

Motorcycle.ts adapter for mostly-dom. Built on @motorcycle/dom.

37 lines (36 loc) 1.75 kB
import { Component } from '@motorcycle/types'; import { DomSinks, DomSources } from './'; /** * Isolates a component by adding an isolation class name to the outermost * DOM element emitted by the component’s view stream. * * The isolation class name is generated by appending the given isolation `key` * to the prefix `$$isolation$$-`, e.g., given `foo` as `key` produces * `$$isolation$$-foo`. * * Isolating components are useful especially when dealing with lists of a * specific component, so that events can be differentiated between the siblings. * However, isolated components are not isolated from access by an ancestor DOM * element. * * Note that `isolate` is curried. * * @name isolate<Sources extends DomSources, Sinks extends DomSinks>(component: Component<Sources, Sinks>, key: string, sources: Sources): Sinks * * @example * import { empty } from '@motorcycle/stream' * import { createDomSource } from '@motorcycle/dom' * * const sources = createDomSource(empty()) * const sinks = isolate(MyComponent, `myIsolationKey`, sources) */ export declare const isolate: IsolatedComponent; export interface IsolatedComponent { <Sources extends DomSources, Sinks extends DomSinks>(component: Component<Sources, Sinks>, key: string, sources: Sources): Sinks; <Sources extends DomSources, Sinks extends DomSinks>(component: Component<Sources, Sinks>, key: string): Component<Sources, Sinks>; <Sources extends DomSources, Sinks extends DomSinks>(component: Component<Sources, Sinks>): IsolatedComponentArity2<Sources, Sinks>; } export interface IsolatedComponentArity2<Sources extends DomSources, Sinks extends DomSinks> { (key: string, sources: Sources): Sinks; (key: string): Component<Sources, Sinks>; }