-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@xstate/store] Add examples + update createStoreWithProducer(…)
#5079
Changes from 1 commit
bc9a898
7c1663e
538f64e
e5cbea5
939bd49
d340dfb
f92863d
07cea21
e21f9bb
6b16f11
b6e3342
e23ccb1
dada479
8a6e30e
c77a40a
726044b
6e688a1
a32f1e8
ee56fe1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,8 @@ export interface Store< | |
*/ | ||
inspect: ( | ||
observer: | ||
| Observer<InspectionEvent> | ||
| ((inspectionEvent: InspectionEvent) => void) | ||
| Observer<StoreInspectionEvent> | ||
| ((inspectionEvent: StoreInspectionEvent) => void) | ||
) => Subscription; | ||
sessionId: string; | ||
on: <TEmittedType extends TEmitted['type']>( | ||
|
@@ -232,14 +232,12 @@ export type EventObject = { | |
}; | ||
type Values<T> = T[keyof T]; | ||
|
||
export type InspectionEvent = | ||
| InspectedSnapshotEvent | ||
| InspectedEventEvent | ||
| InspectedActorEvent | ||
| InspectedMicrostepEvent | ||
| InspectedActionEvent; | ||
export type StoreInspectionEvent = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically this is a breaking change as you have renamed a public export, the same applied to other renamed exports in this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a deprecation instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| StoreInspectedSnapshotEvent | ||
| StoreInspectedEventEvent | ||
| StoreInspectedActorEvent; | ||
|
||
interface BaseInspectionEventProperties { | ||
interface StoreBaseInspectionEventProperties { | ||
rootId: string; // the session ID of the root | ||
/** | ||
* The relevant actorRef for the inspection event. | ||
|
@@ -251,33 +249,26 @@ interface BaseInspectionEventProperties { | |
actorRef: ActorRefLike; | ||
} | ||
|
||
export interface InspectedSnapshotEvent extends BaseInspectionEventProperties { | ||
export interface StoreInspectedSnapshotEvent | ||
extends StoreBaseInspectionEventProperties { | ||
type: '@xstate.snapshot'; | ||
event: AnyEventObject; // { type: string, ... } | ||
snapshot: Snapshot<unknown>; | ||
} | ||
|
||
interface InspectedMicrostepEvent extends BaseInspectionEventProperties { | ||
type: '@xstate.microstep'; | ||
event: AnyEventObject; // { type: string, ... } | ||
snapshot: Snapshot<unknown>; | ||
_transitions: unknown[]; | ||
} | ||
|
||
export interface InspectedActionEvent extends BaseInspectionEventProperties { | ||
export interface StoreInspectedActionEvent | ||
extends StoreBaseInspectionEventProperties { | ||
type: '@xstate.action'; | ||
action: { | ||
type: string; | ||
params: Record<string, unknown>; | ||
}; | ||
} | ||
|
||
export interface InspectedEventEvent extends BaseInspectionEventProperties { | ||
export interface StoreInspectedEventEvent | ||
extends StoreBaseInspectionEventProperties { | ||
type: '@xstate.event'; | ||
// The source might not exist, e.g. when: | ||
// - root init events | ||
// - events sent from external (non-actor) sources | ||
sourceRef: ActorRefLike | undefined; | ||
sourceRef: AnyStore | undefined; | ||
event: AnyEventObject; // { type: string, ... } | ||
} | ||
|
||
|
@@ -286,7 +277,8 @@ interface AnyEventObject { | |
[key: string]: any; | ||
} | ||
|
||
export interface InspectedActorEvent extends BaseInspectionEventProperties { | ||
export interface StoreInspectedActorEvent | ||
extends StoreBaseInspectionEventProperties { | ||
type: '@xstate.actor'; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u might want to add some changeset for this change as without it u wont release
xstate
package and@xstore/store
won't be able to utilize this improvementThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a32f1e8