Options
All
  • Public
  • Public/Protected
  • All
Menu

Library @swim/model

@swim/model

package documentation chat

@swim/model implements a lifecycle-managed model hierarchy supporting dynamic scoping and service injection. @swim/model is part of the @swim/ui framework.

Installation

npm

For an npm-managed project, npm install @swim/model to make it a dependency. TypeScript sources will be installed into node_modules/@swim/model/main. Transpiled JavaScript and TypeScript definition files install into node_modules/@swim/model/lib/main. And a pre-built UMD script can be found in node_modules/@swim/model/dist/main/swim-model.js.

Browser

Browser applications can load swim-ui.js—which bundles the @swim/model library—along with its swim-core.js and swim-mesh.js dependencies, directly from the SwimOS CDN.

<!-- Development -->
<script src="https://cdn.swimos.org/js/latest/swim-core.js"></script>
<script src="https://cdn.swimos.org/js/latest/swim-mesh.js"></script>
<script src="https://cdn.swimos.org/js/latest/swim-ui.js"></script>

<!-- Production -->
<script src="https://cdn.swimos.org/js/latest/swim-core.min.js"></script>
<script src="https://cdn.swimos.org/js/latest/swim-mesh.min.js"></script>
<script src="https://cdn.swimos.org/js/latest/swim-ui.min.js"></script>

Alternatively, the swim-toolkit.js script may be loaded, along with its swim-system.js dependency, from the SwimOS CDN. The swim-toolkit.js script bundles @swim/model together with all other @swim/toolkit frameworks.

<!-- Development -->
<script src="https://cdn.swimos.org/js/latest/swim-system.js"></script>
<script src="https://cdn.swimos.org/js/latest/swim-toolkit.js"></script>

<!-- Production -->
<script src="https://cdn.swimos.org/js/latest/swim-system.min.js"></script>
<script src="https://cdn.swimos.org/js/latest/swim-toolkit.min.js"></script>

Usage

ES6/TypeScript

@swim/model can be imported as an ES6 module from TypeScript and other ES6-compatible environments.

import * as model from "@swim/model";

CommonJS/Node.js

@swim/model can also be used as a CommonJS module in Node.js applications.

var model = require("@swim/model");

Browser

When loaded by a web browser, the swim-ui.js script adds all @swim/model library exports to the global swim namespace. The swim-ui.js script requires that swim-core.js and swim-mesh.js have already been loaded.

The swim-toolkit.js script also adds all @swim/model library exports to the global swim namespace, making it a drop-in replacement for swim-ui.js and swim-model.js when additional @swim/toolkit frameworks are needed.

Index

Classes

Interfaces

Type aliases

Variables

Type aliases

ModelConsumer

ModelConsumer<M>: unknown

Type parameters

ModelConsumerType

ModelConsumerType<M>: M extends { modelConsumers: ReadonlyArray<infer MC> } ? MC : never

Type parameters

ModelContextType

ModelContextType<M>: M extends { modelContext: infer MC } ? MC : unknown

Type parameters

ModelDownlinkConsumer

ModelDownlinkConsumer<M>: unknown

Type parameters

ModelDownlinkConsumerType

ModelDownlinkConsumerType<M>: M extends { downlinkConsumers: ReadonlyArray<infer MC> } ? MC : never

Type parameters

ModelDownlinkDescriptor

ModelDownlinkDescriptor<M, I>: ModelDownlinkInit & ThisType<ModelDownlink<M> & I> & Partial<I>

Type parameters

ModelDownlinkDescriptorExtends

ModelDownlinkDescriptorExtends<M, I>: { extends: ModelDownlinkClass | undefined } & ModelDownlinkDescriptor<M, I>

Type parameters

ModelDownlinkFlags

ModelDownlinkFlags: number

ModelEventDownlinkDescriptor

ModelEventDownlinkDescriptor<M, I>: ModelEventDownlinkInit & ThisType<ModelEventDownlink<M> & I> & Partial<I>

Type parameters

ModelEventDownlinkDescriptorExtends

ModelEventDownlinkDescriptorExtends<M, I>: { extends: ModelEventDownlinkClass | undefined } & ModelEventDownlinkDescriptor<M, I>

Type parameters

ModelFastenerDescriptor

ModelFastenerDescriptor<M, S, U, I>: ModelFastenerInit<S, U> & ThisType<ModelFastener<M, S, U> & I> & Partial<I>

Type parameters

ModelFastenerFlags

ModelFastenerFlags: number

ModelFastenerMemberInit

ModelFastenerMemberInit<M, K>: M[K] extends ModelFastener<any, infer S, infer U> ? S | U : never

Type parameters

  • M

  • K: keyof M

ModelFastenerMemberType

ModelFastenerMemberType<M, K>: M[K] extends ModelFastener<any, infer S, any> ? S : never

Type parameters

  • M

  • K: keyof M

ModelFlags

ModelFlags: number

ModelListDownlinkDescriptor

ModelListDownlinkDescriptor<M, V, VU, I>: ModelListDownlinkInit<V, VU> & ThisType<ModelListDownlink<M, V, VU> & I> & Partial<I>

Type parameters

ModelListDownlinkDescriptorExtends

ModelListDownlinkDescriptorExtends<M, V, VU, I>: { extends: ModelListDownlinkClass | undefined } & ModelListDownlinkDescriptor<M, V, VU, I>

Type parameters

ModelManagerObserverType

ModelManagerObserverType<MM>: MM extends { modelManagerObservers: ReadonlyArray<infer MMO> } ? MMO : never

Type parameters

ModelMapDownlinkDescriptor

ModelMapDownlinkDescriptor<M, K, V, KU, VU, I>: ModelMapDownlinkInit<K, V, KU, VU> & ThisType<ModelMapDownlink<M, K, V, KU, VU> & I> & Partial<I>

Type parameters

ModelMapDownlinkDescriptorExtends

ModelMapDownlinkDescriptorExtends<M, K, V, KU, VU, I>: { extends: ModelMapDownlinkClass | undefined } & ModelMapDownlinkDescriptor<M, K, V, KU, VU, I>

Type parameters

ModelObserverType

ModelObserverType<M>: M extends { modelObservers: ReadonlyArray<infer MO> } ? MO : never

Type parameters

ModelPrecedence

ModelPrecedence: number

ModelPropertyDescriptor

ModelPropertyDescriptor<M, T, U, I>: ModelPropertyInit<T, U> & ThisType<ModelProperty<M, T, U> & I> & Partial<I>

Type parameters

  • M: Model

  • T

  • U = never

  • I = {}

ModelPropertyDescriptorExtends

ModelPropertyDescriptorExtends<M, T, U, I>: { extends: ModelPropertyClass | undefined } & ModelPropertyDescriptor<M, T, U, I>

Type parameters

  • M: Model

  • T

  • U = never

  • I = {}

ModelPropertyDescriptorFromAny

ModelPropertyDescriptorFromAny<M, T, U, I>: { type: FromAny<T, U> } | { fromAny: any } & ModelPropertyDescriptor<M, T, U, I>

Type parameters

  • M: Model

  • T

  • U = never

  • I = {}

ModelPropertyFlags

ModelPropertyFlags: number

ModelPropertyMemberInit

ModelPropertyMemberInit<M, K>: M[K] extends ModelProperty<any, infer T, infer U> ? T | U : never

Type parameters

  • M

  • K: keyof M

ModelPropertyMemberKey

ModelPropertyMemberKey<M, K>: M[K] extends ModelProperty<any, any> ? K : never

Type parameters

  • M

  • K: keyof M

ModelPropertyMemberMap

ModelPropertyMemberMap<M>: {-readonly [ K in keyof M as ModelPropertyMemberKey<M, K>]-?: ModelPropertyMemberInit<M, K> }

Type parameters

  • M

ModelPropertyMemberType

ModelPropertyMemberType<M, K>: M[K] extends ModelProperty<any, infer T, any> ? T : never

Type parameters

  • M

  • K: keyof M

ModelServiceDescriptor

ModelServiceDescriptor<M, T, I>: ModelServiceInit<T> & ThisType<ModelService<M, T> & I> & Partial<I>

Type parameters

ModelServiceDescriptorExtends

ModelServiceDescriptorExtends<M, T, I>: { extends: ModelServiceClass | undefined } & ModelServiceDescriptor<M, T, I>

Type parameters

ModelServiceFlags

ModelServiceFlags: number

ModelServiceMemberType

ModelServiceMemberType<M, K>: M[K] extends ModelService<any, infer T> ? T : never

Type parameters

  • M

  • K: keyof M

ModelTraitDescriptor

ModelTraitDescriptor<M, S, U, I>: ModelTraitInit<S, U> & ThisType<ModelTrait<M, S, U> & I> & Partial<I>

Type parameters

ModelTraitFlags

ModelTraitFlags: number

ModelTraitMemberInit

ModelTraitMemberInit<M, K>: M[K] extends ModelTrait<any, infer S, infer U> ? S | U : never

Type parameters

  • M

  • K: keyof M

ModelTraitMemberType

ModelTraitMemberType<M, K>: M[K] extends ModelTrait<any, infer S, any> ? S : never

Type parameters

  • M

  • K: keyof M

ModelValueDownlinkDescriptor

ModelValueDownlinkDescriptor<M, V, VU, I>: ModelValueDownlinkInit<V, VU> & ThisType<ModelValueDownlink<M, V, VU> & I> & Partial<I>

Type parameters

ModelValueDownlinkDescriptorExtends

ModelValueDownlinkDescriptorExtends<M, V, VU, I>: { extends: ModelValueDownlinkClass | undefined } & ModelValueDownlinkDescriptor<M, V, VU, I>

Type parameters

TraitConsumer

TraitConsumer<R>: unknown

Type parameters

TraitConsumerType

TraitConsumerType<R>: R extends { traitConsumers: ReadonlyArray<infer RC> } ? RC : never

Type parameters

TraitContextType

TraitContextType<R>: ModelContextType<TraitModelType<R>>

Type parameters

TraitFastenerDescriptor

TraitFastenerDescriptor<R, S, U, I>: TraitFastenerInit<S, U> & ThisType<TraitFastener<R, S, U> & I> & Partial<I>

Type parameters

TraitFastenerFlags

TraitFastenerFlags: number

TraitFastenerMemberInit

TraitFastenerMemberInit<R, K>: R[K] extends TraitFastener<any, infer S, infer U> ? S | U : never

Type parameters

  • R

  • K: keyof R

TraitFastenerMemberType

TraitFastenerMemberType<R, K>: R[K] extends TraitFastener<any, infer S, any> ? S : never

Type parameters

  • R

  • K: keyof R

TraitFlags

TraitFlags: number

TraitModelDescriptor

TraitModelDescriptor<R, S, U, I>: TraitModelInit<S, U> & ThisType<TraitModel<R, S, U> & I> & Partial<I>

Type parameters

TraitModelFlags

TraitModelFlags: number

TraitModelMemberInit

TraitModelMemberInit<R, K>: R[K] extends TraitModel<any, infer S, infer U> ? S | U : never

Type parameters

  • R

  • K: keyof R

TraitModelMemberType

TraitModelMemberType<R, K>: R[K] extends TraitModel<any, infer S, any> ? S : never

Type parameters

  • R

  • K: keyof R

TraitModelType

TraitModelType<R>: R extends { model: infer M } ? M extends null ? never : M : Model

Type parameters

TraitObserverType

TraitObserverType<R>: R extends { traitObservers: ReadonlyArray<infer RO> } ? RO : never

Type parameters

TraitPropertyDescriptor

TraitPropertyDescriptor<R, T, U, I>: TraitPropertyInit<T, U> & ThisType<TraitProperty<R, T, U> & I> & Partial<I>

Type parameters

  • R: Trait

  • T

  • U = never

  • I = {}

TraitPropertyDescriptorExtends

TraitPropertyDescriptorExtends<R, T, U, I>: { extends: TraitPropertyClass | undefined } & TraitPropertyDescriptor<R, T, U, I>

Type parameters

  • R: Trait

  • T

  • U = never

  • I = {}

TraitPropertyDescriptorFromAny

TraitPropertyDescriptorFromAny<R, T, U, I>: { type: FromAny<T, U> } | { fromAny: any } & TraitPropertyDescriptor<R, T, U, I>

Type parameters

  • R: Trait

  • T

  • U = never

  • I = {}

TraitPropertyFlags

TraitPropertyFlags: number

TraitPropertyMemberInit

TraitPropertyMemberInit<R, K>: R[K] extends TraitProperty<any, infer T, infer U> ? T | U : never

Type parameters

  • R

  • K: keyof R

TraitPropertyMemberKey

TraitPropertyMemberKey<R, K>: R[K] extends TraitProperty<any, any> ? K : never

Type parameters

  • R

  • K: keyof R

TraitPropertyMemberMap

TraitPropertyMemberMap<R>: {-readonly [ K in keyof R as TraitPropertyMemberKey<R, K>]-?: TraitPropertyMemberInit<R, K> }

Type parameters

  • R

TraitPropertyMemberType

TraitPropertyMemberType<R, K>: R[K] extends TraitProperty<any, infer T, any> ? T : never

Type parameters

  • R

  • K: keyof R

TraitServiceDescriptor

TraitServiceDescriptor<R, T, I>: TraitServiceInit<T> & ThisType<TraitService<R, T> & I> & Partial<I>

Type parameters

TraitServiceDescriptorExtends

TraitServiceDescriptorExtends<R, T, I>: { extends: TraitServiceClass | undefined } & TraitServiceDescriptor<R, T, I>

Type parameters

TraitServiceMemberType

TraitServiceMemberType<R, K>: R[K] extends TraitService<any, infer T> ? T : never

Type parameters

  • R

  • K: keyof R

Variables

ModelContext

ModelContext: { default: any }

Type declaration

  • default: function
    • Returns ModelContext

ModelDownlink

ModelDownlink: { ConsumingFlag: number; MountedFlag: number; PendingFlag: number; RelinkMask: number; prototype: ModelDownlink<any>; define: any }

Type declaration

ModelDownlinkContext

ModelDownlinkContext: { decorateModelDownlink: any; getModelDownlinkConstructor: any; initModelDownlinks: any }

Type declaration

ModelEventDownlink

ModelEventDownlink: { prototype: ModelEventDownlink<any>; define: any }

Type declaration

ModelFastener

ModelFastener: { MountedFlag: number; prototype: ModelFastener<any, any, never>; define: any }

Type declaration

ModelListDownlink

ModelListDownlink: { prototype: ModelListDownlink<any, Value, never>; define: any }

Type declaration

ModelMapDownlink

ModelMapDownlink: { prototype: ModelMapDownlink<any, any, any, never, never>; define: any }

Type declaration

ModelProperty

ModelProperty: { InheritedFlag: number; MountedFlag: number; OverrideFlag: number; UpdatedFlag: number; prototype: ModelProperty<any, any, never>; define: any; getClass: any }

Type declaration

    • Type parameters

      • M: Model<M>

      • T: undefined | string = undefined | string

      • U: undefined | string = undefined | string

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • M_1: Model<M_1>

      • T_1: undefined | boolean = undefined | boolean

      • U_1: undefined | string | boolean = undefined | string | boolean

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • M_2: Model<M_2>

      • T_2: undefined | number = undefined | number

      • U_2: undefined | string | number = undefined | string | number

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • M_3: Model<M_3>

      • T_3

      • U_3 = never

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • M_4: Model<M_4>

      • T_4

      • U_4 = never

      • I = {}

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • M_5: Model<M_5>

      • T_5

      • U_5 = never

      Parameters

      Returns PropertyDecorator

  • InheritedFlag: number
  • MountedFlag: number
  • OverrideFlag: number
  • UpdatedFlag: number
  • prototype: ModelProperty<any, any, never>
  • define: function
  • getClass: function
    • Parameters

      • type: unknown

      Returns null | ModelPropertyClass

ModelService

ModelService: { InheritedFlag: number; prototype: ModelService<any, any>; define: any; getClass: any }

Type declaration

ModelTrait

ModelTrait: { MountedFlag: number; prototype: ModelTrait<any, any, never>; define: any }

Type declaration

ModelValueDownlink

ModelValueDownlink: { prototype: ModelValueDownlink<any, any, never>; define: any }

Type declaration

TraitFastener

TraitFastener: { MountedFlag: number; prototype: TraitFastener<any, any, never>; define: any }

Type declaration

TraitModel

TraitModel: { MountedFlag: number; prototype: TraitModel<any, any, never>; define: any }

Type declaration

TraitProperty

TraitProperty: { InheritedFlag: number; MountedFlag: number; OverrideFlag: number; UpdatedFlag: number; prototype: TraitProperty<any, any, never>; define: any; getClass: any }

Type declaration

    • Type parameters

      • R: Trait<R>

      • T: undefined | string = undefined | string

      • U: undefined | string = undefined | string

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • R_1: Trait<R_1>

      • T_1: undefined | boolean = undefined | boolean

      • U_1: undefined | string | boolean = undefined | string | boolean

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • R_2: Trait<R_2>

      • T_2: undefined | number = undefined | number

      • U_2: undefined | string | number = undefined | string | number

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • R_3: Trait<R_3>

      • T_3

      • U_3 = never

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • R_4: Trait<R_4>

      • T_4

      • U_4 = never

      • I = {}

      Parameters

      Returns PropertyDecorator

    • Type parameters

      • R_5: Trait<R_5>

      • T_5

      • U_5 = never

      Parameters

      Returns PropertyDecorator

  • InheritedFlag: number
  • MountedFlag: number
  • OverrideFlag: number
  • UpdatedFlag: number
  • prototype: TraitProperty<any, any, never>
  • define: function
  • getClass: function
    • Parameters

      • type: unknown

      Returns null | TraitPropertyClass

TraitService

TraitService: { prototype: TraitService<any, any>; define: any }

Type declaration

Generated using TypeDoc