-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stores): stores library for nanoviews (#29)
- Loading branch information
Showing
64 changed files
with
11,350 additions
and
5,539 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
"rules": { | ||
}, | ||
"ignorePatterns": [ | ||
"packages/*/dist/**/*" | ||
"packages/*/dist/**/*", | ||
"packages/*/package/**/*" | ||
] | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nodejs 22.4.1 | ||
pnpm 9.9.0 |
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"extends": [ | ||
"@trigen/eslint-config/typescript", | ||
"@trigen/eslint-config/typescript-requiring-type-checking", | ||
"@trigen/eslint-config/jest" | ||
], | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"tsconfigRootDir": "./packages/stores", | ||
"project": ["./tsconfig.json"] | ||
}, | ||
"rules": { | ||
"@typescript-eslint/no-invalid-void-type": "off", | ||
"@typescript-eslint/restrict-template-expressions": "off", | ||
"no-implicit-coercion": "off", | ||
"consistent-return": "off", | ||
"symbol-description": "off" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
{ | ||
"name": "All publics", | ||
"path": "dist/index.js", | ||
"import": "*", | ||
"limit": "2.36 kB" | ||
}, | ||
{ | ||
"name": "All internals", | ||
"path": "dist/internals.js", | ||
"import": "*", | ||
"limit": "1.5 kB" | ||
}, | ||
{ | ||
"name": "Atom", | ||
"path": "dist/index.js", | ||
"import": "{ atom }", | ||
"limit": "297 B" | ||
}, | ||
{ | ||
"name": "Popular set", | ||
"path": "dist/index.js", | ||
"import": "{ atom, record, computed, listen, subscribe }", | ||
"limit": "963 B" | ||
} | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# @nanoviews/stores | ||
|
||
[![ESM-only package][package]][package-url] | ||
[![NPM version][npm]][npm-url] | ||
[![Dependencies status][deps]][deps-url] | ||
[![Install size][size]][size-url] | ||
[![Build status][build]][build-url] | ||
[![Coverage status][coverage]][coverage-url] | ||
|
||
[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg | ||
[package-url]: https://nodejs.org/api/esm.html | ||
|
||
[npm]: https://img.shields.io/npm/v/%40nanoviews%2Fstores.svg | ||
[npm-url]: https://npmjs.com/package/@nanoviews/stores | ||
|
||
[deps]: https://img.shields.io/librariesio/release/npm/%40nanoviews%2Fstores | ||
[deps-url]: https://libraries.io/npm/%40nanoviews%2Fstores/tree | ||
|
||
[size]: https://packagephobia.com/badge?p=%40nanoviews%2Fstores | ||
[size-url]: https://packagephobia.com/result?p=%40nanoviews%2Fstores | ||
|
||
[build]: https://img.shields.io/github/actions/workflow/status/TrigenSoftware/nanoviews/tests.yml?branch=main | ||
[build-url]: https://github.com/TrigenSoftware/nanoviews/actions | ||
|
||
[coverage]: https://img.shields.io/codecov/c/github/TrigenSoftware/nanoviews.svg | ||
[coverage-url]: https://app.codecov.io/gh/TrigenSoftware/nanoviews | ||
|
||
A small state management library for Nanoviews inspired by [Nano Stores](https://github.com/nanostores/nanostores). | ||
|
||
- **Small**. Between 297 B and 2.36 kB (minified and brotlied). Zero dependencies. | ||
- **Fast**. With small atomic and computed stores, you do not need to call the selector function for all components on every store change. | ||
- Designed for best **Tree-Shaking**: only the code you use is included in your bundle. | ||
- **TypeScript**-first. | ||
|
||
```ts | ||
// store/users.ts | ||
import { list, push, record } from '@nanoviews/stores' | ||
|
||
export const $users = list([] as User[], record) | ||
|
||
export function addUser(user: User) { | ||
push($users, user) | ||
} | ||
``` | ||
|
||
```ts | ||
// store/admins.ts | ||
import { computed, list, record } from '@nanoviews/stores' | ||
import { $users } from './users.js' | ||
|
||
export const $admins = list( | ||
computed($users, users => users.filter(i => i.isAdmin)), | ||
record | ||
) | ||
``` | ||
|
||
```tsx | ||
// components/admins.ts | ||
import { $admins } from '../stores/admins.js' | ||
|
||
export const Admins = component$(() => ul()( | ||
for$($admins, admin => li()(admin.name)) | ||
)) | ||
``` | ||
|
||
<hr /> | ||
<a href="#install">Install</a> | ||
<!-- span> • </span --> | ||
<br /> | ||
<hr /> | ||
|
||
## Install | ||
|
||
```bash | ||
pnpm add -D @nanoviews/stores | ||
# or | ||
npm i -D @nanoviews/stores | ||
# or | ||
yarn add -D @nanoviews/stores | ||
``` | ||
|
||
*...Work in progress...* |
Oops, something went wrong.