update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 18:24:08 +02:00
parent 8c0125a8c0
commit 8c3a7aa637
4 changed files with 155 additions and 30 deletions

View File

@ -9,12 +9,24 @@
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartstate",
"description": "a package that handles state in a good way",
"description": "A package for handling and managing state in applications.",
"npmPackagename": "@push.rocks/smartstate",
"license": "MIT"
"license": "MIT",
"keywords": [
"state management",
"reactive programming",
"TypeScript",
"observables",
"web storage",
"state action",
"state selection",
"state notification",
"asynchronous state",
"cumulative notification"
]
}
},
"tsdocs": {
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

View File

@ -2,7 +2,7 @@
"name": "@push.rocks/smartstate",
"version": "2.0.17",
"private": false,
"description": "a package that handles state in a good way",
"description": "A package for handling and managing state in applications.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
@ -43,5 +43,17 @@
],
"browserslist": [
"last 1 chrome versions"
],
"keywords": [
"state management",
"reactive programming",
"TypeScript",
"observables",
"web storage",
"state action",
"state selection",
"state notification",
"asynchronous state",
"cumulative notification"
]
}
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

150
readme.md
View File

@ -1,37 +1,137 @@
# @push.rocks/smartstate
a package that handles state in a good way
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartstate)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartstate)
* [github.com (source mirror)](https://github.com/push.rocks/smartstate)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartstate/)
## Install
## Status for master
To install `@push.rocks/smartstate`, you can use npm (Node Package Manager). Run the following command in your terminal:
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartstate/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartstate/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartstate)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartstate)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartstate)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartstate)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartstate)](https://lossless.cloud)
```bash
npm install @push.rocks/smartstate --save
```
This will add `@push.rocks/smartstate` to your project's dependencies.
## Usage
Use TypeScript for best in class intellisense.
The `@push.rocks/smartstate` library provides an elegant way to handle state within your JavaScript or TypeScript projects, leveraging the power of Reactive Extensions (RxJS) and a structured state management strategy. In the following sections, we will explore the comprehensive capabilities of this package and how to effectively use them in various scenarios, ensuring a robust state management pattern in your applications.
## Contribution
### Getting Started
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
First, let's import the necessary components from the library:
For further information read the linked docs at the top of this readme.
```typescript
import { Smartstate, StatePart, StateAction } from '@push.rocks/smartstate';
```
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
### Creating a SmartState Instance
`Smartstate` acts as the container for your state parts. You can consider it as the root of your state management structure.
```typescript
const myAppSmartState = new Smartstate<YourStatePartNamesEnum>();
```
### Defining State Parts
State parts represent separable sections of your state, making it easier to manage and modularize. For example, you may have a state part for user data and another for application settings.
Define an enum for state part names for better management:
```typescript
enum AppStateParts {
UserState,
SettingsState
}
```
Now, let's create a state part within our `myAppSmartState` instance:
```typescript
interface IUserState {
isLoggedIn: boolean;
username?: string;
}
const userStatePart = await myAppSmartState.getStatePart<IUserState>(
AppStateParts.UserState,
{ isLoggedIn: false } // Initial state
);
```
### Subscribing to State Changes
You can subscribe to changes in a state part to perform actions accordingly:
```typescript
userStatePart.select().subscribe((currentState) => {
console.log(`User Logged In: ${currentState.isLoggedIn}`);
});
```
If you need to select a specific part of your state, you can pass a selector function:
```typescript
userStatePart.select(state => state.username).subscribe((username) => {
if (username) {
console.log(`Current user: ${username}`);
}
});
```
### Modifying State with Actions
Create actions to modify the state in a controlled manner:
```typescript
interface ILoginPayload {
username: string;
}
const loginUserAction = userStatePart.createAction<ILoginPayload>(async (statePart, payload) => {
return { ...statePart.getState(), isLoggedIn: true, username: payload.username };
});
// Dispatch the action to update the state
loginUserAction.trigger({ username: 'johnDoe' });
```
### Persistent State
`Smartstate` supports the concept of persistent states, where you can maintain state across sessions. To utilize this, specify a persistent mode when getting a state part:
```typescript
const settingsStatePart = await myAppSmartState.getStatePart<AppStateParts, ISettingsState>(
AppStateParts.SettingsState,
{ theme: 'light' }, // Initial state
'persistent' // Mode
);
```
This mode ensures that the state is saved and can be reloaded even after the application restarts, providing a seamless user experience.
### Comprehensive Usage
Putting it all together, `@push.rocks/smartstate` offers a flexible and powerful pattern for managing application state. By modularizing state parts, subscribing to state changes, and controlling state modifications through actions, developers can maintain a clean and scalable architecture. Combining these strategies with persistent states unlocks the full potential for creating dynamic and user-friendly applications.
Remember to leverage TypeScript for its excellent support for types and interfaces, enhancing your development experience with type checking and IntelliSense, ensuring a more reliable and maintainable codebase.
For more complex scenarios, consider combining multiple state parts, creating hierarchical state structures, and integrating with other state management solutions as needed. With `@push.rocks/smartstate`, the possibilities are vast, empowering you to tailor the state management approach to fit the unique requirements of your project.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.