Skip to content

Add reusable shared resource factory functions#8

Merged
HichemTab-tech merged 5 commits intomasterfrom
add-static-states-creation
Sep 5, 2025
Merged

Add reusable shared resource factory functions#8
HichemTab-tech merged 5 commits intomasterfrom
add-static-states-creation

Conversation

@HichemTab-tech
Copy link
Owner

🚀 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

  • Added createSharedState, createSharedFunction, and createSharedSubscription factory functions.
  • Updated demo app to use createSharedState from the external library for consistency.
  • Expanded README with comprehensive examples and API documentation for shared resources.
  • Enhanced build process by including TypeScript compilation in the build script.
  • Introduced .editorconfig rules for consistent formatting of JSON and YAML files.

🛠️ Fixes or Features

  • Fix: If the PR fixes a bug, describe which bug it fixes.
  • Feature: Introduced reusable shared resource factories and streamlined integration.

🔬 Testing

  • Manual testing steps:
    • Step 1: Verify createSharedState, createSharedFunction, and createSharedSubscription functionality through the demo app and examples.
    • Step 2: Run the updated build process to ensure proper TypeScript compilation and code output alignment.

📚 Documentation

  • Documentation has been updated as needed (README, etc.).
  • The change has been explained in relevant docs.

- 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.
@HichemTab-tech HichemTab-tech changed the title Expand shared resource documentation and enhance build process Add reusable shared resource factory functions Sep 5, 2025
@HichemTab-tech HichemTab-tech merged commit f0acd50 into master Sep 5, 2025
1 check passed
@HichemTab-tech HichemTab-tech deleted the add-static-states-creation branch September 5, 2025 21:14
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