Skip to content
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

Refactor CommandEngine to JSON-RPC #11

Merged
merged 7 commits into from
May 17, 2021

Conversation

shanejonas
Copy link
Contributor

fixes #10

@shanejonas shanejonas force-pushed the refactor-command-engine-to-jsonrpc branch from 037434a to 94e90fa Compare May 14, 2021 22:08
@shanejonas shanejonas requested review from rekmarks, a team and Gudahtt May 14, 2021 22:11
Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

Nice! If I didn't know about the ID rabbit hole I'd say this looked like it was easy 😅

packages/controllers/src/plugins/PluginController.ts Outdated Show resolved Hide resolved
.editorconfig Outdated Show resolved Hide resolved
packages/controllers/src/idCounter.ts Outdated Show resolved Hide resolved
packages/controllers/src/idCounter.ts Outdated Show resolved Hide resolved
packages/controllers/src/workers/WorkerController.ts Outdated Show resolved Hide resolved
packages/controllers/src/workers/WorkerController.ts Outdated Show resolved Hide resolved
packages/controllers/src/workers/WorkerController.ts Outdated Show resolved Hide resolved
packages/workers/src/PluginWorker.ts Outdated Show resolved Hide resolved
packages/workers/src/PluginWorker.ts Outdated Show resolved Hide resolved

if (!id || typeof id !== 'string') {
if (!id && typeof id !== 'string' && typeof id !== 'number') {
Copy link
Member

Choose a reason for hiding this comment

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

We have complete control over the IDs that come in over this stream, so I think we can mostly keep the original implementation, and just expect either a number or string.

If we're expecting a number, I think we can just do the following, unless we want to e.g. enforce that the numbers are integers.

Suggested change
if (!id && typeof id !== 'string' && typeof id !== 'number') {
if (typeof id !== 'number') {

Copy link
Member

Choose a reason for hiding this comment

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

This check will permit the empty string as an id. Since we're using nanoid now, I think we can revert this and go with the original condition.

@rekmarks rekmarks changed the title refactor CommandEngine to JSON-RPC Refactor CommandEngine to JSON-RPC May 17, 2021
@shanejonas shanejonas force-pushed the refactor-command-engine-to-jsonrpc branch from 57174dc to 0d356c9 Compare May 17, 2021 20:47
@shanejonas shanejonas requested a review from rekmarks May 17, 2021 21:00

if (!id || typeof id !== 'string') {
if (!id && typeof id !== 'string' && typeof id !== 'number') {
Copy link
Member

Choose a reason for hiding this comment

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

This check will permit the empty string as an id. Since we're using nanoid now, I think we can revert this and go with the original condition.

@shanejonas shanejonas force-pushed the refactor-command-engine-to-jsonrpc branch from 6e165c3 to 3d554c7 Compare May 17, 2021 23:17
@shanejonas shanejonas force-pushed the refactor-command-engine-to-jsonrpc branch from 3d554c7 to 3e08fc1 Compare May 17, 2021 23:26
Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

Let's gooo!

@shanejonas shanejonas merged commit 554d3c9 into main May 17, 2021
@shanejonas shanejonas deleted the refactor-command-engine-to-jsonrpc branch May 17, 2021 23:32
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.

Replace the web worker controller's CommandEngine with json-rpc-engine
2 participants