Skip to content

Add sync module#104

Merged
streamich merged 3 commits intomainfrom
sync
Mar 20, 2026
Merged

Add sync module#104
streamich merged 3 commits intomainfrom
sync

Conversation

@streamich
Copy link
Copy Markdown
Owner

Introduces very light-weight Signal-like reactive primitives that work well with React.js external sync store.

import {val, comp} from 'thingies';

const view = val<'display' | 'edit'>('display');
const formatting = comp([view], (view) => {
  if (view !== 'edit') return;
  return new Formatting(123);
});

Copilot AI review requested due to automatic review settings March 20, 2026 10:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new sync module providing lightweight synchronous reactive primitives (Value, Computed) intended to integrate with React’s useSyncExternalStore, along with tests and documentation, and updates the Jest toolchain.

Changes:

  • Introduces src/sync.ts with Value, Computed, and val/comp helpers.
  • Exposes the new module via src/index.ts and documents it in README.md.
  • Adds comprehensive Jest tests for the new primitives and upgrades Jest/@types/jest dependencies (with corresponding lockfile updates).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
yarn.lock Updates dependency lockfile due to Jest/tooling upgrades.
src/sync.ts Adds reactive sync primitives and React external-store-compatible interfaces.
src/index.ts Re-exports the new sync module from the package entrypoint.
src/tests/sync.spec.ts Adds test coverage for Value/Computed behavior, caching, and disposal.
package.json Upgrades Jest + typings (toolchain impact).
README.md Documents the new Value/Computed primitives and factories.
Comments suppressed due to low confidence (1)

package.json:54

  • Jest was bumped to v30 but ts-jest is still on the v29 line, while the test runner is configured to transform TS via ts-jest (jest.config.js). In yarn.lock, ts-jest@29.3.0 pulls jest-util@^29.0.0, which is a strong indicator it targets Jest 29 APIs. Please align versions (upgrade ts-jest to a Jest-30-compatible release, or keep Jest on v29) to avoid runtime/transform incompatibilities in CI.
    "@types/jest": "^30.0.0",
    "benchmark": "^2.1.4",
    "husky": "^8.0.0",
    "jest": "^30.3.0",
    "prettier": "^3.0.0",
    "pretty-quick": "^3.1.1",
    "rimraf": "^3.0.2",
    "ts-jest": "^29.1.2",
    "tslib": "^2.6.2",

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sync.ts
Comment on lines +30 to +32
this.value = value;
}

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace after the closing brace; this can cause unnecessary diffs and may fail stricter linters/formatters. Please remove the trailing space.

Copilot uses AI. Check for mistakes.
Comment thread src/sync.ts
Comment on lines +95 to +98
}

export const val = <V>(initial: V): Value<V> => new Value(initial);
export const comp = <V extends unknown[], N>(deps: WrapListInSyncDep<V>, compute: (args: V) => N): Computed<N, V> =>
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The public API currently passes dependency snapshots as a single array/tuple argument (compute(args: V)), but the PR description example uses a single-value callback (comp([view], (view) => ...)). As implemented, that example would receive [view] (an array) rather than view. Either update the API to call compute(...snapshots) (and type it as (...args: V) => N) or update the docs/examples to reflect the tuple-argument shape (([view]) => ...).

Copilot uses AI. Check for mistakes.
@streamich streamich merged commit fad19f5 into main Mar 20, 2026
1 check passed
@streamich streamich deleted the sync branch March 20, 2026 10:56
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants