-
Notifications
You must be signed in to change notification settings - Fork 450
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
Conversation
`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.
NB: The sketchy thing I've done in this PR is re-use the existing |
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.
I believe we decided during Wednesday's meeting that this was OK.
Once you merge, I'll publish the change sometime next week.
The `afterSubmit` hook was [replaced with `afterWrite`][1]. [1]: share/sharedb#314
The `afterSubmit` hook was [replaced with `afterWrite`][1]. [1]: share/sharedb#314
* [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
* [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
Fixes #313
afterSubmit
is a potentially confusing middleware hook, as it mightsuggest 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.