Skip to content

Andarist/mailbox unification#2916

Merged
davidkpiano merged 7 commits intov5/mailboxfrom
andarist/mailbox-unification
Jan 9, 2022
Merged

Andarist/mailbox unification#2916
davidkpiano merged 7 commits intov5/mailboxfrom
andarist/mailbox-unification

Conversation

@Andarist
Copy link
Collaborator

@Andarist Andarist commented Jan 3, 2022

No description provided.

@Andarist Andarist requested a review from davidkpiano January 3, 2022 15:56
@changeset-bot
Copy link

changeset-bot bot commented Jan 3, 2022

⚠️ No Changeset found

Latest commit: ea41473

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ghost
Copy link

ghost commented Jan 3, 2022

CodeSee Review Map:

Review these changes using an interactive CodeSee Map

Review in an interactive map

View more CodeSee Maps

Legend

CodeSee Map Legend

# Conflicts:
#	packages/core/src/actor.ts
#	packages/core/src/behaviors.ts
Comment on lines +179 to +190
this.context._event =
typeof event.type !== 'string'
? (event as LifecycleSignal)
: toSCXMLEvent(event as TEvent);

this.current = this.behavior.transition(
this.current,
typeof this.context._event.type !== 'string'
? (this.context._event as LifecycleSignal)
: (this.context._event as SCXML.Event<TEvent>).data,
this.context
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite ugly but I didn't want to touch this any further in this PR. Refining the type with TS was not possible here because apparently, TS has problems when it comes to distinguishing strings and symbols:
TS playground

I've just found isSignal helper in the codebase and I could use it here - but OTOH I think that using symbols here is not buying as anything and it's just annoying to work with so I would like to propose adjusting those signals to use plain strings.

Comment on lines +20 to +23
useEffect(() => {
actorRef.start!();
return () => actorRef!.stop!();
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top-level actorRefs are required to have start method because we need to start them in a "deferred" manner. We can't start them when rendering in the React world - this has to be done in an effect

Comment on lines +164 to +169
start() {
mailbox.start();
},
stop() {
mailbox.clear();
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an urgent need to define "primitive types" of XState. Quite frankly, I'm getting lost in that - there are a lot of similar, yet slightly different abstractions introduced in the codebase and it's hard to manage their responsibilities because they are not entirely well-defined. I think that I understand most of them but yet the implementation doesn't mirror what I assume and this is confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you list exactly what's confusing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically what we've discussed last week - atm behaviors are not so pure but they should be. Whatever responsibilities are managed by behaviors should be pulled into actors.

_event: null as any
};

state = behavior.start ? behavior.start(actorCtx) : state;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same argument as here. We can't execute start when rendering.

};
},
start() {
mailbox.start();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this most likely should also start a behavior or something, but I'm not sure about the relationships between different primitive types (as mentioned in another comment). All tests are passing at the moment - so at the very least this is under-specified and we should make sure those primitive types and communication protocols etc are well-defined and covered by tests.

@davidkpiano
Copy link
Member

We'll merge this into v5/mailbox and continue work from there.

@davidkpiano davidkpiano merged commit 0af90a3 into v5/mailbox Jan 9, 2022
@davidkpiano davidkpiano deleted the andarist/mailbox-unification branch January 9, 2022 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants