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

Rename afterSubmit middleware hook to afterWrite #314

Merged
merged 1 commit into from
Oct 21, 2019
Merged

Conversation

alecgibson
Copy link
Collaborator

Fixes #313

afterSubmit is a potentially confusing middleware hook, as it might
suggest that it takes place after an op has been submitted, but before
it has been processed and committed.

This change renames the hook to the slightly clearer afterWrite hook,
which conveys that the op has actually been written.

`afterSubmit` is a potentially confusing middleware hook, as it might
suggest that it takes place after an op has been submitted, but _before_
it has been processed and committed.

This change renames the hook to the slightly clearer `afterWrite` hook,
which conveys that the op has actually been written.
@alecgibson
Copy link
Collaborator Author

NB: The sketchy thing I've done in this PR is re-use the existing after submit shim, which means that anyone who has disabled that warning will not get warned that afterSubmit is going to be deprecated as well. If we really care, I can add a whole new shim?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 95.957% when pulling 52e94ba on after-write into f01cf0e on master.

Copy link
Contributor

@ericyhwang ericyhwang left a comment

Choose a reason for hiding this comment

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

I believe we decided during Wednesday's meeting that this was OK.

Once you merge, I'll publish the change sometime next week.

@alecgibson alecgibson merged commit b9a72eb into master Oct 21, 2019
@alecgibson alecgibson deleted the after-write branch October 21, 2019 07:05
alecgibson added a commit to alecgibson/DefinitelyTyped that referenced this pull request Jan 14, 2021
The `afterSubmit` hook was [replaced with `afterWrite`][1].

[1]: share/sharedb#314
alecgibson added a commit to alecgibson/DefinitelyTyped that referenced this pull request Jan 20, 2021
The `afterSubmit` hook was [replaced with `afterWrite`][1].

[1]: share/sharedb#314
typescript-bot pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Jan 20, 2021
* [sharedb] Server event support

This change makes the default `sharedb` class extend `EventEmitter`,
like it does [in the library][1].

We also add support for the [`error`][2] and [`timing`][3] events.

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L21
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L91
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L220

* [sharedb] Add MilestoneDB support

The `Backend` options allow specifying a [`milestoneDb`][1], which is an
instance of [`MilestoneDB`][2].

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L28
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/milestone-db/index.js#L7

* [sharedb] Update Backend options

This change adds support for the [`suppressPublish`][1] and
[`maxSubmitRetries`][2] options.

We also mark `disableDocAction` and `disableSpaceDelimitedActions` as
deprecated, because these were [removed][3].

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L33
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L34
[3]: share/sharedb#311

* [sharedb] Update Doc definitions

This change makes multiple fixes to the `Doc` definition:

 - Add [`subscribed`][1], [`preventCompose`][2] and [`paused`][3]
  properties
 - Add [`unsubscribe()`][4]
 - Allow a callback in [`destroy()`][5]
 - Remove the error argument from [`whenNothingPending()`][6], since that
   method will never call the callback with an error
 - Add [`hasPending()`][7], [`hasWritePending()`][8], [`pause()`][9],
   [`resume()`][10] and [`flush()`][11] methods

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L73
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L104
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L109
[4]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L424
[5]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L113
[6]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L221
[7]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L232
[8]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L243
[9]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L901
[10]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L906
[11]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L500

* [sharedb] Snapshots

ShareDB allows clients to fetch snapshots through:

 - [`fetchSnapshot`][1]
 - [`fetchSnapshotByTimestamp`][2]

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L660
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L688

* [sharedb] Generic Doc and Snapshot

The `Doc` and `Snapshot` types are both data wrappers around a
potentially well-structured object.

This change makes these types optionally generic (defaulting to `any`
if no type is provided), allowing clients to enforce stricter type
checking on these types if they wish.

* [sharedb] Update middleware hooks

The `afterSubmit` hook was [replaced with `afterWrite`][1].

[1]: share/sharedb#314

* [sharedb] Logger method overrides

ShareDB exposes a special [`Logger`][1], which can be used to override
ShareDB's internal logging calls, which default to using the `console`.

There are two logger instances that can be configured:

 - [server-side][2]
 - [client-side][3]

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/logger/logger.js#L7
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/index.js#L8
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/index.js#L6

* [sharedb] Presence support

ShareDB supports "presence", which is accessed through
[`getPresence`][1] and [`getDocPresence`][2], both of which return an
instance of [`Presence`][3].

This functionality is hidden behind a [feature flag][4], which is also
included in this change.

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L751
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L758
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/presence/presence.js#L8
[4]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L35

* [sharedb] Update authors

* Review markups

 - Fix bad merge: `disableDocAction` is the deprecated field.
 - Make `Doc` callbacks optional
 - Rename `ReceivePresence` to a more obvious name
kaznovac pushed a commit to kaznovac/DefinitelyTyped that referenced this pull request Mar 2, 2021
* [sharedb] Server event support

This change makes the default `sharedb` class extend `EventEmitter`,
like it does [in the library][1].

We also add support for the [`error`][2] and [`timing`][3] events.

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L21
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L91
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L220

* [sharedb] Add MilestoneDB support

The `Backend` options allow specifying a [`milestoneDb`][1], which is an
instance of [`MilestoneDB`][2].

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L28
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/milestone-db/index.js#L7

* [sharedb] Update Backend options

This change adds support for the [`suppressPublish`][1] and
[`maxSubmitRetries`][2] options.

We also mark `disableDocAction` and `disableSpaceDelimitedActions` as
deprecated, because these were [removed][3].

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L33
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L34
[3]: share/sharedb#311

* [sharedb] Update Doc definitions

This change makes multiple fixes to the `Doc` definition:

 - Add [`subscribed`][1], [`preventCompose`][2] and [`paused`][3]
  properties
 - Add [`unsubscribe()`][4]
 - Allow a callback in [`destroy()`][5]
 - Remove the error argument from [`whenNothingPending()`][6], since that
   method will never call the callback with an error
 - Add [`hasPending()`][7], [`hasWritePending()`][8], [`pause()`][9],
   [`resume()`][10] and [`flush()`][11] methods

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L73
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L104
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L109
[4]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L424
[5]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L113
[6]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L221
[7]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L232
[8]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L243
[9]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L901
[10]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L906
[11]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/doc.js#L500

* [sharedb] Snapshots

ShareDB allows clients to fetch snapshots through:

 - [`fetchSnapshot`][1]
 - [`fetchSnapshotByTimestamp`][2]

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L660
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L688

* [sharedb] Generic Doc and Snapshot

The `Doc` and `Snapshot` types are both data wrappers around a
potentially well-structured object.

This change makes these types optionally generic (defaulting to `any`
if no type is provided), allowing clients to enforce stricter type
checking on these types if they wish.

* [sharedb] Update middleware hooks

The `afterSubmit` hook was [replaced with `afterWrite`][1].

[1]: share/sharedb#314

* [sharedb] Logger method overrides

ShareDB exposes a special [`Logger`][1], which can be used to override
ShareDB's internal logging calls, which default to using the `console`.

There are two logger instances that can be configured:

 - [server-side][2]
 - [client-side][3]

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/logger/logger.js#L7
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/index.js#L8
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/index.js#L6

* [sharedb] Presence support

ShareDB supports "presence", which is accessed through
[`getPresence`][1] and [`getDocPresence`][2], both of which return an
instance of [`Presence`][3].

This functionality is hidden behind a [feature flag][4], which is also
included in this change.

[1]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L751
[2]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/connection.js#L758
[3]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/client/presence/presence.js#L8
[4]: https://github.com/share/sharedb/blob/30badb22192eb04e43f983772058fb129598de51/lib/backend.js#L35

* [sharedb] Update authors

* Review markups

 - Fix bad merge: `disableDocAction` is the deprecated field.
 - Make `Doc` callbacks optional
 - Rename `ReceivePresence` to a more obvious name
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.

Rename afterSubmit hook?
3 participants