Skip to content

Commit 4536532

Browse files
committed
Migrate action and guard params
1 parent a9dbc86 commit 4536532

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

docs/actions.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const feedbackMachine = createMachine({
2727
}
2828
}, {
2929
actions: {
30-
track: ({ action }) => {
31-
track(action.params);
30+
track: (_, params) => {
31+
track(params);
3232
// tracks { response: 'good' }
3333
},
3434
showConfetti: () => {
@@ -249,7 +249,7 @@ const feedbackMachine = createMachine(
249249
{
250250
// highlight-start
251251
actions: {
252-
track: ({ context, event }) => {
252+
track: ({ context, event }, params) => {
253253
// Action implementation
254254
// ...
255255
},
@@ -266,7 +266,7 @@ const feedbackActor = createActor(
266266
// highlight-start
267267
feedbackMachine.provide({
268268
actions: {
269-
track: ({ context, event }) => {
269+
track: ({ context, event }, params) => {
270270
// Overridden action implementation
271271
// ...
272272
},

docs/cheatsheet.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ const machine = createMachine({
266266
const actor = createActor(
267267
machine.provide({
268268
actions: {
269-
notify: ({ action }) => {
270-
console.log(action.params.message ?? 'Default message');
269+
notify: (_, params) => {
270+
console.log(params.message ?? 'Default message');
271271
},
272272
activate: () => {
273273
console.log('Activating');
@@ -337,8 +337,8 @@ const actor = createActor(
337337
// highlight-start
338338
guards: {
339339
canBeToggled: ({ context }) => context.canActivate,
340-
isAfterTime: ({ guard }) => {
341-
const { time } = guard.params;
340+
isAfterTime: (_, params) => {
341+
const { time } = params;
342342
const [hour, minute] = time.split(':');
343343
const now = new Date();
344344
return now.getHours() > hour && now.getMinutes() > minute;

docs/guards.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ const feedbackMachine = createMachine(
143143
{
144144
// highlight-start
145145
guards: {
146-
isValid: ({ context, guard }) => {
146+
isValid: ({ context }, params) => {
147147
return (
148148
context.feedback.length > 0 &&
149-
context.feedback.length <= guard.maxLength
149+
context.feedback.length <= params.maxLength
150150
);
151151
},
152152
},
@@ -162,10 +162,10 @@ const feedbackActor = createActor(
162162
// highlight-start
163163
feedbackMachine.provide({
164164
guards: {
165-
isValid: ({ context, guard }) => {
165+
isValid: ({ context }, params) => {
166166
return (
167167
context.feedback.length > 0 &&
168-
context.feedback.length <= guard.maxLength &&
168+
context.feedback.length <= params.maxLength &&
169169
isNotSpam(context.feedback)
170170
);
171171
},

0 commit comments

Comments
 (0)