Skip to content

Commit 15e5992

Browse files
committed
@@ -0,0 +1,13 @@
- initial version: basic readme tests in place major release pending: more documentation integration with ctx-core (including front-end component library)
1 parent 59b9313 commit 15e5992

File tree

7 files changed

+148
-2
lines changed

7 files changed

+148
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
COMMIT_EDITMSG

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# @ctx-core/rmemo
2+
3+
## 0.1.0
4+
5+
### Minor Changes
6+
7+
- initial version:
8+
9+
basic readme
10+
tests in place
11+
major release pending:
12+
more documentation
13+
integration with ctx-core (including front-end component library)

README.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,67 @@
1-
# rmemo
2-
Tiny Reactive Memo + Signal library (377B)
1+
# rmemo (Reactive Memo)
2+
rmemo is a tiny (377B) no-fluff state management library using reactive memos & reactive signals for the server &
3+
browser. This includes:
4+
5+
* reactive memos
6+
* reactive signals
7+
* autosubscriptions
8+
* async support
9+
* a terse & focused api
10+
* performance
11+
* integration with garbage collector
12+
13+
## usage
14+
15+
```ts
16+
import { rmemo_, rsig_ } from 'rmemo'
17+
18+
export const user_a$ = rsig_<User[]>([], async user_a$ => {
19+
user_a$(await fetch('https://an.api/users').then(res => res.json()))
20+
})
21+
22+
export function user__add(user: User) {
23+
user_a$([...user_a$(), user])
24+
// also supports ._ getters & setters
25+
// user_a$._ = [...user_a$._, user]
26+
}
27+
```
28+
```ts
29+
// store/admins.ts
30+
import { rmemo_ } from 'rmemo'
31+
import { user_a$ } from './users.js'
32+
33+
export const admin_a$ = rmemo_(() => user_a$().filter(i => i.isAdmin))
34+
```
35+
36+
*Integrations with front-end frameworks pending...*
37+
38+
## motivation
39+
40+
I'm a fan of reactive state management solutions provided by nanostores, solidjs, svelte, & vanJS. I wanted one of
41+
these solutions to be a general solution that I can use on the browser & server, with web UIs & domain libraries.
42+
Each of these projects are focused on their particular objectives. I found they were unable to support my use cases
43+
in one way or another.
44+
45+
Between an impasse in adding autosubscriptions to nanostores & adding server-side reactive support to vanJS, I
46+
created rmemo.
47+
48+
## how is rmemo different?
49+
50+
rmemo is a small & focused library. It supports `rmemo_` (like nanostores `computed`, svelte `derived`,
51+
solidjs `createMemo`, & VanJS `derive`) & `rsig_` (like nanostore `atom`, svelte `writable`, solidjs
52+
`createSignal`, & VanJS `state`).
53+
54+
| **** | **rmemo** | **nanostores** | **solidjs** | **sveltejs** | **vanjs** |
55+
|-------------------------------------|-----------|------------------|------------------|--------------|-----------|
56+
| **small payload** ||||||
57+
| **performant** ||||||
58+
| **autosubscriptions** ||||||
59+
| **server side reactivity** ||||||
60+
| **diamond dependencies** ||||||
61+
| **independent from component tree** ||| ❌ (next version) |||
62+
| **reactive async** || ❌ (next version) ||||
63+
| **terse api** ||||||
64+
| **ecosystem of libraries** ||||||
65+
66+
It will not support contexts. A general purpose context library, such as ctx-core fulfills that need in a more
67+
effective manner. Note that ctx-core can be used with any of these libraries.

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from 'ctx-core/rmemo'

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from 'ctx-core/rmemo'

package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "rmemo",
3+
"version": "0.1.0",
4+
"description": "ctx-core rmemo",
5+
"keywords": [
6+
"ctx-core",
7+
"rmemo",
8+
"reactive memo",
9+
"reactive signal"
10+
],
11+
"homepage": "https://github.com/ctx-core/rmemo#readme",
12+
"bugs": {
13+
"url": "https://github.com/ctx-core/rmemo/issues"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/ctx-core/rmemo.git"
18+
},
19+
"license": "Apache-2.0",
20+
"author": "Brian Takita",
21+
"type": "module",
22+
"types": "./index.d.ts",
23+
"exports": {
24+
".": "./index.js",
25+
"./package.json": "./package.json"
26+
},
27+
"scripts": {
28+
"build": ":",
29+
"clean": ":",
30+
"exec": "$@",
31+
"prepublishOnly": "pnpm clean && pnpm build",
32+
"test": "pnpm test-unit && check-dts",
33+
"test-unit": "tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
34+
"test-unit-coverage": "c8 pnpm test-unit"
35+
},
36+
"dependencies": {
37+
"ctx-core": "^3.0.0"
38+
},
39+
"devDependencies": {
40+
"c8": "^8.0.1",
41+
"check-dts": "^0.7.2",
42+
"tsx": "^4.1.2",
43+
"typescript": "next",
44+
"uvu": "^0.5.6"
45+
},
46+
"publishConfig": {
47+
"access": "public",
48+
"cache": "~/.npm"
49+
},
50+
"sideEffects": false
51+
}

tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compileOnSave": true,
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"moduleResolution": "nodenext",
6+
"target": "ESNext",
7+
"strict": true
8+
},
9+
"exclude": [
10+
"node_modules"
11+
],
12+
"references": []
13+
}

0 commit comments

Comments
 (0)