share / share/sharedb

Changing op during `submit` hook does not refresh client

Open
#375 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
6.5k
Forks
456
Avg merge
1d 5h
Merged PRs (30d)
5

Description

Let's say there are two users, A and B. And there is this on submit middleware hook that converts the content to uppercase:

backend.use("submit", (ctx, cb) => {
  try {
    ctx.op.op[0].si = ctx.op.op[0].si.toUpperCase();
  } catch (e) {}
  cb();
});

When user A writes "q" user B will see "Q" but user A will still see "q" unless he refreshes the browser.

How can I broadcast on submit middleware changes to the client that initiated the op??

Or, otherwise: Is there any other middleware hook meant to do something like this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the submit middleware example with two users and trace how the submit hook processes the initiating client's operation. Determine how the transformed content is propagated to that client; done means user A sees the uppercase value without refreshing while user B continues to receive it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.