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

feat(preview): add unstable_observeDocument(s) to preview store #7176

Merged
merged 6 commits into from
Jul 22, 2024

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Jul 17, 2024

Description

This adds two new methods to the preview store:

unstable_observeDocument(documentId: string): Observable<SanityDocument>
unstable_observeDocuments(documentIds: string[]): Observable<SanityDocument[]>

These will emit full documents as opposed to the other methods in the preview store that takes in a list of path selectors and returns partial documents with only the given paths selected.

The reason it's part of the preview store is so that we can re-use the global listener connection we currently use for previews - philosophically it makes sense to keep them here as well, since they update with a higher latency than documents that has realtime editing capabilities, and is therefore better suited for "previewing" purposes.

Since we do have the full document in these cases, we can apply the patches as they arrive from the backend, and doesn't need to do the ordinary refetching that we do for regular previews where only partial documents are kept locally.

These methods are useful for cases where you don't need the optimistic patching logic provided by the document store, but still require the full document to be loaded. The use case at hand is to load a list of documents and show their validation status in a view that doesn't support editing, but still needs to receive realtime updates in case they are being edited by other collaborators.

These are only meant for internal use (for now)

What to review

Testing

  • Will fast track this into next later on, will look into getting some additional tests in place then.

Notes for release

n/a - internal

Copy link

vercel bot commented Jul 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2024 9:32am
performance-studio ✅ Ready (Inspect) Visit Preview Jul 22, 2024 9:32am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2024 9:32am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2024 9:32am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2024 9:32am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jul 22, 2024 9:32am

Copy link
Contributor

No changes to documentation

@bjoerge bjoerge force-pushed the corel branch 2 times, most recently from 8cbc89d to c5254fe Compare July 17, 2024 12:30
bjoerge added a commit that referenced this pull request Jul 30, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
bjoerge added a commit that referenced this pull request Aug 2, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
juice49 pushed a commit that referenced this pull request Aug 4, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
juice49 pushed a commit that referenced this pull request Aug 6, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
bjoerge added a commit that referenced this pull request Aug 7, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
bjoerge added a commit that referenced this pull request Aug 16, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
bjoerge added a commit that referenced this pull request Aug 20, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
bjoerge added a commit that referenced this pull request Aug 20, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
bjoerge added a commit that referenced this pull request Aug 20, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
RitaDias pushed a commit that referenced this pull request Aug 23, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
RitaDias pushed a commit that referenced this pull request Aug 26, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
juice49 pushed a commit that referenced this pull request Sep 3, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
RitaDias pushed a commit that referenced this pull request Oct 3, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
juice49 pushed a commit that referenced this pull request Oct 4, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
juice49 pushed a commit that referenced this pull request Oct 7, 2024
)

* chore: remove futile circular dependency workaround

* refactor(core): lift global listener out of preview store

* fix(preview): cleanup code so it matches current conventions + add some docs

* feat(preview): add unstable_observeDocument + unstable_observeDocuments to preview store

* fix: use includeMutations: false

* fix: expect ts error on includeMutations: false for now
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.

2 participants