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

test: example app #21

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft

test: example app #21

wants to merge 21 commits into from

Conversation

johannes-lindgren
Copy link
Collaborator

@johannes-lindgren johannes-lindgren commented Jan 23, 2025

A basic example application for two purposes:

Testing

A simple test to test that:

  1. package JSON exports is configured correctly
  2. type declarations and the bundle is generated correctly
  3. That some essential functions and types are exported from the library

If there's an issue, the dependent React application will fail to type check and build.

Documentation

As a demo to draw inspiration from. When using this library for the first time, I found the barrier to entry to be a bit higher than necessary. The idea is to demonstrate:

  1. Asynchronous loading: the current example in the Readme only shows how to utilize a global state that is initialized at the time the module is loaded. However, in a real-world scenario, the application will likely connect the Yjs document to some server or local storage.
  2. Non-global state: the example in the readme loads the document in the module, but a real-world application might want to be more flexible, for example by using React's context API.
  3. How to handle type safety. When passing the type argument to binder<T>(), Immer-yjs essentially asserts the type. However, the user might want to validate the document to guarantee proper type safety. (I developed a validation library just for this purpose—PureParse—to deal specifically with data from CRDTs)
  4. Example on how to integrate with React. The readme uses an outdated function useSyncExternalStoreWithSelector: React now has useSyncExternalStore.

@johannes-lindgren johannes-lindgren self-assigned this Jan 23, 2025
@sep2 sep2 marked this pull request as ready for review January 25, 2025 13:02
@johannes-lindgren johannes-lindgren changed the base branch from chore/immer-v10 to main January 25, 2025 14:31
@johannes-lindgren johannes-lindgren marked this pull request as draft January 25, 2025 14:35
@johannes-lindgren
Copy link
Collaborator Author

@sep2 I'm converting to draft, because I am working on this right 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.

1 participant