Skip to content

Latest commit

 

History

History
237 lines (140 loc) · 5.85 KB

globals.md

File metadata and controls

237 lines (140 loc) · 5.85 KB

behavior-state

Globals

behavior-state

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

ObserverListProps

Ƭ ObserverListProps: object

Defined in react/index.ts:50

Type declaration:


ObserverProps

Ƭ ObserverProps: object & T extends ReactNode ? { next?: (value: T) => ReactNode; } : { next: (value: T) => ReactNode; }

Defined in preact/Observer.ts:12

Defined in react/Observer.ts:12

Defined in react/index.ts:14

Properties of the <Observer .../> component Properties of the <Observer .../> component


ProtectedState

Ƭ ProtectedState: object

Defined in seal.ts:7

Make all Behavior / Subject properties in T asObservable(). The resulting ProtectedState will not allow anyone to call .next() on any Behaviors.

Type declaration:


SealState

Ƭ SealState: object

Defined in seal.ts:12

Strict State type which enforces that each property is either a void function, or an Observable

Type declaration:

  • [ propertyOrAction: string]: function | Observable‹any›

TLength

Ƭ TLength: number | string

Defined in spring/CSS.ts:3

Variables

Const INIT_ITEM

INIT_ITEM: unique symbol = Symbol("unallocated")

Defined in BehaviorList.ts:78


Const REMOVED_ITEM

REMOVED_ITEM: unique symbol = Symbol("removed")

Defined in BehaviorList.ts:79

Functions

seal

seal<T>(state: T): ProtectedState‹T›

Defined in seal.ts:24

Protects a State from exposing mutable Behaviors or Subjects, and exposes those as Observables.

Ensure that the users of this State are not able to call .next() on the behaviors passed in. Additionally, types for protectState ensure that the shape of the State follows State best practices.

Type parameters:

T: SealState

Parameters:

Name Type Description
state T set of Behavior / Observable values and action functions controlling the state

Returns: ProtectedState‹T›


shouldStopAnimation

shouldStopAnimation(value: number, destination: number, velocity: number): boolean

Defined in spring/shouldStopAnimation.ts:1

Parameters:

Name Type
value number
destination number
velocity number

Returns: boolean


spyOnObservable

spyOnObservable<T>(obs: Observable‹T›): SpyOnObservable‹T›

Defined in jest/index.ts:47

Type parameters:

T

Parameters:

Name Type
obs Observable‹T›

Returns: SpyOnObservable‹T›


spyOnState

spyOnState<T>(state: T): SpyOnState‹Unwrap‹T››

Defined in jest/index.ts:34

Test State observable values by extending each observable with .nextValue: Promise<T> and .latestValue: T for easier testing with jest

Example:

const todos = spyOnState(createTodosState());

expect(todos.$todoInput.latestValue).toBe("")
// this is a promise, so we must resolve
expect(todos.$todoInput.nextValue).resolve.toBe("new value")

// this will update $todoInput, and the expect will test it
todos.updateInput("new value")

Type parameters:

T

Parameters:

Name Type
state T

Returns: SpyOnState‹Unwrap‹T››


stepper

stepper(secondPerFrame: number, x: number, v: number, destX: number, k: number, b: number, precision: number): [number, number]

Defined in spring/stepper.ts:6

Parameters:

Name Type
secondPerFrame number
x number
v number
destX number
k number
b number
precision number

Returns: [number, number]