-
Notifications
You must be signed in to change notification settings - Fork 0
@ralphschuler.state store.StateStore.StateStore
@ralphschuler/state-store.StateStore.StateStore
Class responsible for managing application state and notifying listeners about changes. Utilizes Proxy for intercepting state property assignments.
Name | Type | Description |
---|---|---|
StateType |
extends StateProperties
|
The type of the state this store will manage. |
• new StateStore<StateType
>(state
): StateStore
<StateType
>
Initializes a new StateStore instance.
Name | Type |
---|---|
StateType |
extends StateProperties
|
Name | Type | Description |
---|---|---|
state |
StateType |
The initial state of the store. |
StateStore
<StateType
>
• Protected
interceptors: Interceptors
<StateType
> = {}
• Protected
listeners: Listeners
<StateType
> = {}
• Protected
middlewares: Middlewares
<StateType
> = {}
• Protected
state: StateType
▸ applyInterceptors<PropertyKey
>(property
, value
): StateType
[PropertyKey
]
Applies interceptors for a given property.
Name | Type | Description |
---|---|---|
PropertyKey |
extends string | number | symbol
|
The key of the property for which interceptors are to be applied. |
Name | Type | Description |
---|---|---|
property |
PropertyKey |
The property for which interceptors should be applied. |
value |
StateType [PropertyKey ] |
The value to be passed through interceptors. |
StateType
[PropertyKey
]
The value after passing through all interceptors.
▸ applyMiddlewares<PropertyKey
>(property
, value
, next
): void
Applies middlewares for a given property.
Name | Type | Description |
---|---|---|
PropertyKey |
extends string | number | symbol
|
The key of the property for which middlewares are to be applied. |
Name | Type | Description |
---|---|---|
property |
PropertyKey |
The property for which middlewares should be applied. |
value |
StateType [PropertyKey ] |
The value to be passed through middlewares. |
next |
() => void
|
The callback to invoke after all middlewares have been applied. |
void
▸ createProxy(): StateStore
<StateType
>
Creates a proxy to handle get and set operations transparently.
StateStore
<StateType
>
A proxy wrapped instance of the StateStore.
▸ notifyListeners<PropertyKey
>(property
, value
): void
Notifies all listeners about a change in state for a given property.
Name | Type | Description |
---|---|---|
PropertyKey |
extends string | number | symbol
|
The key of the property for which listeners are to be notified. |
Name | Type | Description |
---|---|---|
property |
PropertyKey |
The property that has changed. |
value |
StateType [PropertyKey ] |
The new value of the property. |
void
▸ updateState<PropertyKey
>(property
, value
): void
Updates the state for a given property and notifies the relevant listeners. Applies interceptors and middlewares before updating the state.
Name | Type | Description |
---|---|---|
PropertyKey |
extends string | number | symbol
|
The key of the property to be updated. |
Name | Type | Description |
---|---|---|
property |
PropertyKey |
The property to update. |
value |
StateType [PropertyKey ] |
The new value for the property. |
void
- @ralphschuler/ai-function-caller
- index
- types/AIFunction
- types/Message
- @ralphschuler/assert
- assert
- assert
- assert
- assert
- assert
- assert
- assert
- assert
- assert
- assert
- assert
- assert
- assert
- error
- index
- util
- @ralphschuler/better-map
- @ralphschuler/better-set
- @ralphschuler/binary-serializer
- @ralphschuler/bit-mask
- @ralphschuler/complex-compare
- @ralphschuler/i811n
- @ralphschuler/logger
- Color
- ColorMap
- Logger
- animations/BallonAnimation
- animations/BaseAnimation
- animations/BombAnimation
- animations/BouncingBallAnimation
- animations/ClockAnimation
- animations/DotsAnimation
- animations/HorizontalBarAnimation
- animations/PongAnimation
- animations/ProgressAnimation
- animations/ProgressBarAnimation
- animations/SpinnerAnimation
- animations/VerticalBarAnimation
- enums/LogLevel
- index
- interfaces/IColor
- interfaces/IMessage
- types/ColorName
- types/Colors
- @ralphschuler/lsystem
- @ralphschuler/mixin-class-factory
- @ralphschuler/neuronal-network
- @ralphschuler/parser-combinator
- index
- inputTypes
- parser
- unicode
- @ralphschuler/prom-metrics-decorator
- @ralphschuler/prom-metrics-parser
- @ralphschuler/random
- PseudoRandomItemSelector
- PseudoRandomNumberGenerator
- Seed
- index
- strategies
- strategy
- strategy
- strategy
- strategy
- strategy
- strategy
- types
- type
- type
- type
- @ralphschuler/safe-array
- @ralphschuler/slot-mashine
- @ralphschuler/state-store
- StateStore
- index
- type
- type
- type
- type
- type
- type
- type
- type
- util
- @ralphschuler/stats-tracker
- @ralphschuler/ts-error
- error
- index
- type
- util
- util
- util
- util
- @ralphschuler/webgl-sand-engine
- index
- pixel-renderer
- @ralphschuler/webgl-shader-factory
- "node:stream/consumers"
- "node:stream/promises"
- ChatCompletionSnapshot
- Choice
- Message
- ToolCall
- EventEmitter
- FormData
- OpenAI
- OpenAI
- Audio
- Speech
- Transcriptions
- Translations
- Beta
- Assistants
- Assistant
- AssistantCreateParams
- AssistantUpdateParams
- Files
- Chat
- Threads
- Messages
- Files
- MessageContentImageFile
- MessageContentText
- Text
- FileCitation
- FilePath
- Runs
- RequiredActionFunctionToolCall
- Run
- RequiredAction
- RunCreateParams
- RunSubmitToolOutputsParams
- Steps
- CodeToolCall
- CodeInterpreter
- Image
- FunctionToolCall
- MessageCreationStepDetails
- RunStep
- ThreadCreateAndRunParams
- Thread
- ThreadCreateParams
- Chat
- Completions
- ChatCompletion
- ChatCompletionAssistantMessageParam
- ChatCompletionChunk
- Choice
- Delta
- ToolCall
- ChatCompletionContentPartImage
- ChatCompletionCreateParams
- ChatCompletionMessage
- ChatCompletionMessageToolCall
- ChatCompletionNamedToolChoice
- Completions
- CompletionChoice
- CompletionCreateParams
- Edits
- Edit
- Embeddings
- CreateEmbeddingResponse
- Files
- FineTunes
- FineTune
- FineTuneCreateParams
- FineTuneListEventsParams
- FineTuning
- Jobs
- FineTuningJob
- JobCreateParams
- Images
- Models
- Moderations
- Moderation
- internal
- finished
- pipeline
- "node:stream/consumers"
- "node:stream/promises"
- EventEmitter
- internal
- finished
- pipeline
- Counter
- Gauge
- Histogram
- Summary