Skip to content

Detailed documentation/test missing for ingestSnapshot #254

Closed

Description

@curran

Currently there are no tests that invoke ingestSnapshot directly.

Such tests would be useful in documenting exactly how one could go about using ingestSnapshot, which is IMO not clear from the current documentation. For example, after reading "This data must include a version, snapshot and type.", I'm still not sure what to pass in exactly. I'd guess an object with properties version, snapshot and type, but still not sure what kinds of values would be expected.

Activity

  1. changed the title [-]Test for ingestSnapshot[/-] [+]Detailed documentation/test missing for ingestSnapshot[/+] on Nov 5, 2018
  2. curran commented on Nov 5, 2018

    @curran
    ContributorAuthor

    In particular, I had difficulty finding out how to construct a snapshot from a fetched ShareDB.Doc.

    I eventually did get it to work, and here's the solution:

    const doc = connection.get('examples', 'textarea');
    const snapshot = {
      v: doc.version,
      data: doc.data
    };

    This may be a good example to put in the README.

  3. ericyhwang commented on Nov 6, 2018

    @ericyhwang
    Contributor

    Yup, the documentation isn't as precise as it could be. The JSDoc for ingestSnapshot is clearer - it says it requires v, data, and type fields on the snapshot param.
    https://github.com/share/sharedb/blob/v1.0.0-beta.14/lib/client/doc.js#L150

    I've updated the README in a67ad42 to clarify the format for the param.

    Any additional clarifications on the documentation that you'd like?

    Re the tests, ingestSnapshot gets covered indirectly by doc fetch/subscribe. As you say, it could be useful to have a simple test as "enforced" documentation. If you want to add one, that'd be great!

  4. curran commented on Nov 6, 2018

    @curran
    ContributorAuthor

    Thanks a ton @ericyhwang for making that update!

  5. curran commented on Nov 6, 2018

    @curran
    ContributorAuthor

    Closing as the update is IMO suffucient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions