Add reusable shared resource factory functions#8
Merged
HichemTab-tech merged 5 commits intomasterfrom Sep 5, 2025
Merged
Conversation
- Added `indent_size = 2` for `*.yml` to ensure consistent YAML formatting. - Added `indent_size = 2` for `*.json` to enforce uniform JSON formatting.
- Updated the `build` script to include `tsc` for TypeScript compilation before running `vite build`. - Added a new `tsc` script for standalone TypeScript compilation. - Ensures proper type-checking and generation of type definitions during the build process.
…redSubscription`. - Added factory functions (`createSharedState`, `createSharedFunction`, `createSharedSubscription`) for initializing shared resources with `key` generation and scoped prefixes. - Updated `useSharedState`, `useSharedFunction`, and `useSharedSubscription` to accept created objects as arguments, providing streamlined usage. - Introduced generic `SharedCreated` type for unified handling of shared resources. - Refactored utility functions to include a `random` key generator for consistent key creation. - Updated SharedData methods (`clear` and `resolve`) to accept the new shared objects. - Adjusted documentation exports to include the new types and functions. - Improved demo examples to showcase the new features.
Replaced the local `createSharedState` import with the one from the `react-shared-states` package to ensure the demo app reflects the library's intended usage. - Simplifies and aligns the demo app with the external library usage.
- Added documentation for `createSharedState`, `createSharedFunction`, and `createSharedSubscription` with examples to encourage best practices in large apps. - Updated examples to demonstrate explicit scope naming for shared resources, avoiding collisions and enhancing type safety. - Enhanced API reference with detailed usage for static/shared resource creation and integration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Purpose
This PR introduces reusable shared resource factory functions and enhances the development workflow by improving documentation, aligning the demo app with the library, and adding strict TypeScript checks to the build process.
🧑💻 Changes
createSharedState,createSharedFunction, andcreateSharedSubscriptionfactory functions.createSharedStatefrom the external library for consistency.buildscript..editorconfigrules for consistent formatting of JSON and YAML files.🛠️ Fixes or Features
🔬 Testing
createSharedState,createSharedFunction, andcreateSharedSubscriptionfunctionality through the demo app and examples.📚 Documentation