258 Commits

Author SHA1 Message Date
Julien Valverdé
076007ec67 Refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-27 18:52:08 +02:00
Julien Valverdé
dd524e1aa5 Refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-27 18:46:33 +02:00
Julien Valverdé
1c7cef703b SubRef
All checks were successful
Lint / lint (push) Successful in 17s
2025-04-25 13:50:54 +02:00
Julien Valverdé
fa0f8c6b24 Refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-25 13:38:42 +02:00
Julien Valverdé
357e5aa56b useSubRef
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-25 10:16:04 +02:00
Julien Valverdé
ea374d7e0f Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-25 08:32:42 +02:00
Julien Valverdé
148c98acbd Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-25 08:30:17 +02:00
Julien Valverdé
39d2176c61 Working subref from path
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-25 08:21:59 +02:00
Julien Valverdé
107ff1e794 SubscriptionSubRef.makeFromPath
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-25 08:12:34 +02:00
Julien Valverdé
a70ef27f75 PropertyPath done
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-25 07:56:56 +02:00
Julien Valverdé
04b2fad038 PropertyPath
All checks were successful
Lint / lint (push) Successful in 29s
2025-04-25 07:40:21 +02:00
Julien Valverdé
691b28427d SearchPaths work
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-24 00:52:18 +02:00
Julien Valverdé
1de976aaa8 Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-24 00:20:30 +02:00
Julien Valverdé
df851cf9ee SearchPaths work
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-23 07:06:32 +02:00
Julien Valverdé
459f548c10 Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-23 06:50:17 +02:00
Julien Valverdé
6156baec4d SearchPaths work
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-23 06:47:11 +02:00
Julien Valverdé
1163b83929 SearchPaths work
Some checks failed
Lint / lint (push) Failing after 13s
2025-04-23 05:53:19 +02:00
Julien Valverdé
8917f84952 SearchPaths work
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-22 22:59:50 +02:00
Julien Valverdé
58752253b3 SearchPaths work
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-22 22:36:17 +02:00
Julien Valverdé
ba362baf04 SearchPaths work
All checks were successful
Lint / lint (push) Successful in 15s
2025-04-22 21:55:59 +02:00
Julien Valverdé
33cf4fbcbd Tests
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-21 05:15:55 +02:00
Julien Valverdé
e8f92c88b8 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-21 03:17:41 +02:00
Julien Valverdé
6ae155de34 Version bump
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-21 02:53:31 +02:00
Julien Valverdé
db783f174e Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-21 02:52:50 +02:00
Julien Valverdé
2b48695e54 Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 12s
2025-04-21 02:12:13 +02:00
Julien Valverdé
ab441fe982 Fix
All checks were successful
Lint / lint (push) Successful in 13s
Test build / test-build (pull_request) Successful in 44s
2025-04-21 02:01:24 +02:00
Julien Valverdé
eabcf9085b useSubRefFromGetSet
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-21 01:21:59 +02:00
Julien Valverdé
926482b154 Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-20 19:38:18 +02:00
Julien Valverdé
110b0813f8 Refactoring
All checks were successful
Lint / lint (push) Successful in 29s
2025-04-20 06:14:58 +02:00
Julien Valverdé
974af95a22 Version bump
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-20 05:32:19 +02:00
Julien Valverdé
d6e1d445e8 Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-20 05:28:44 +02:00
Julien Valverdé
d8d6e87a12 Refactoring
Some checks failed
Lint / lint (push) Failing after 13s
2025-04-20 05:26:31 +02:00
Julien Valverdé
682e473bf7 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-20 05:10:51 +02:00
Julien Valverdé
31dd7b5fdb Working SubscriptionSubRef
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-20 05:06:48 +02:00
Julien Valverdé
17686e68c3 SubscriptionSubRef
All checks were successful
Lint / lint (push) Successful in 18s
2025-04-20 04:34:01 +02:00
Julien Valverdé
49d4bd4d43 SubscriptionSubRef work
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-20 00:22:24 +02:00
Julien Valverdé
be88035936 SubscriptionSubRef
Some checks failed
Lint / lint (push) Failing after 10s
2025-04-19 03:42:48 +02:00
Julien Valverdé
3497d17046 Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-14 00:58:05 +02:00
Julien Valverdé
1ca832e69d Fix
All checks were successful
Lint / lint (push) Successful in 14s
Test build / test-build (pull_request) Successful in 21s
2025-04-14 00:54:06 +02:00
Julien Valverdé
98bd72d1d7 Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-13 18:29:00 +02:00
Julien Valverdé
f594f47793 VQueryErrorHandler
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-13 17:39:54 +02:00
Julien Valverdé
4f9827720c Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-13 17:18:06 +02:00
Julien Valverdé
0f761524fd Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-13 17:06:20 +02:00
Julien Valverdé
574136e161 SubscribeStream
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-13 03:21:11 +02:00
Julien Valverdé
7a12abdbdf useSubscribeStream
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-13 02:30:29 +02:00
Julien Valverdé
8fecb94292 Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-12 23:59:40 +02:00
Julien Valverdé
26a2111705 Version bump
All checks were successful
Lint / lint (push) Successful in 14s
Test build / test-build (pull_request) Successful in 43s
2025-04-12 23:52:35 +02:00
Julien Valverdé
1cb02407c8 Dependencies fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-12 23:47:43 +02:00
Julien Valverdé
6e8ce84851 Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-12 23:06:43 +02:00
Julien Valverdé
570fb93876 ReffuseHelpers -> ReffuseNamespace
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-12 23:03:17 +02:00
Julien Valverdé
821fd18f8f Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-12 18:30:37 +02:00
Julien Valverdé
b7ef95341b Tests
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-12 00:39:02 +02:00
Julien Valverdé
5f5ef5614b Working SubscribeRefs
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-12 00:16:04 +02:00
Julien Valverdé
cbd39f893e Done useSubscribeRefs
All checks were successful
Lint / lint (push) Successful in 16s
2025-04-11 23:40:06 +02:00
Julien Valverdé
529e3d3f9d useSubscribeRefs work
Some checks failed
Lint / lint (push) Failing after 10s
2025-04-11 21:43:32 +02:00
Julien Valverdé
9d47418a69 useRefsState work
Some checks failed
Lint / lint (push) Failing after 10s
2025-04-11 20:10:34 +02:00
Julien Valverdé
c1b6e73231 useRefsState work
All checks were successful
Lint / lint (push) Successful in 13s
2025-04-11 02:58:44 +02:00
Julien Valverdé
d1ba4148f2 useRefsState work
Some checks failed
Lint / lint (push) Failing after 11s
2025-04-11 02:10:21 +02:00
Julien Valverdé
ef13e87d12 Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-11 00:23:15 +02:00
Julien Valverdé
8b141b907f RefState tests
All checks were successful
Lint / lint (push) Successful in 14s
2025-04-10 23:06:13 +02:00
Julien Valverdé
52a36cb882 RefState component
All checks were successful
Lint / lint (push) Successful in 58s
2025-04-10 22:38:29 +02:00
Julien Valverdé
3b844f071b Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-31 21:43:29 +02:00
Julien Valverdé
4e422a1901 Version bump
All checks were successful
Lint / lint (push) Successful in 13s
Test build / test-build (pull_request) Successful in 17s
2025-03-31 21:40:55 +02:00
Julien Valverdé
a5c6b34dfe Example fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-31 21:19:41 +02:00
Julien Valverdé
ab1f851428 Refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-31 21:07:42 +02:00
Julien Valverdé
3f091d55c2 QueryClient refactoring
All checks were successful
Lint / lint (push) Successful in 17s
2025-03-31 20:54:32 +02:00
Julien Valverdé
76a33fccca Query refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-31 20:38:21 +02:00
Julien Valverdé
c75bb10e6b QueryClient work
Some checks failed
Lint / lint (push) Failing after 17s
2025-03-31 18:22:18 +02:00
Julien Valverdé
3da4b2a318 QueryClient work
Some checks failed
Lint / lint (push) Failing after 14s
2025-03-31 01:54:08 +02:00
Julien Valverdé
9a24ecaf84 QueryClient work
Some checks failed
Lint / lint (push) Failing after 14s
2025-03-31 00:00:47 +02:00
Julien Valverdé
7b20df6c71 Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-28 21:26:06 +01:00
Julien Valverdé
f40dae90fb Version bump
All checks were successful
Lint / lint (push) Successful in 13s
Test build / test-build (pull_request) Successful in 44s
2025-03-28 21:22:32 +01:00
Julien Valverdé
46211638f5 Refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-28 21:19:17 +01:00
Julien Valverdé
a28d6c3d30 Refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-28 21:12:42 +01:00
Julien Valverdé
6b74b9a3b2 useMemoScoped refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-28 21:09:27 +01:00
Julien Valverdé
e17f945666 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-28 20:30:31 +01:00
Julien Valverdé
aa46ecc82d Async provider refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-28 20:27:25 +01:00
Julien Valverdé
8ea9146dd9 Provider refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-28 19:18:46 +01:00
Julien Valverdé
0a4bb2856d Provider refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-28 18:48:49 +01:00
Julien Valverdé
b4cd7daa81 Restore
Some checks failed
Lint / lint (push) Failing after 26s
2025-03-28 18:26:04 +01:00
Julien Valverdé
b5712d5433 Test
All checks were successful
Lint / lint (push) Successful in 36s
2025-03-28 17:39:23 +01:00
Julien Valverdé
57b7eac05c Test 2025-03-28 17:37:28 +01:00
Julien Valverdé
9a9bd78ec6 Provider work
Some checks failed
Lint / lint (push) Failing after 10s
2025-03-28 17:01:41 +01:00
Julien Valverdé
ddcd681ca4 Provider refactoring
Some checks failed
Lint / lint (push) Failing after 19m51s
2025-03-28 16:08:04 +01:00
Julien Valverdé
66de517ab5 Refactoring
Some checks failed
Lint / lint (push) Failing after 15m36s
2025-03-26 20:24:53 +01:00
Julien Valverdé
b50255ded2 Merge branch 'queryclient' of git.valverde.cloud:Thilawyn/reffuse into queryclient
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-26 19:34:59 +01:00
Julien Valverdé
03f0b623ed Removed JSX code 2025-03-26 19:34:21 +01:00
Julien Valverdé
fb6d803723 Removed JSX code 2025-03-26 19:34:14 +01:00
Julien Valverdé
972986241c ReffuseHelpers.make()
Some checks failed
Lint / lint (push) Has been cancelled
2025-03-25 19:29:17 +01:00
Julien Valverdé
9eb0904600 Refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-24 20:35:22 +01:00
Julien Valverdé
fc86c818e0 Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-24 19:41:21 +01:00
Julien Valverdé
5a12139602 Regenerated lockfile
All checks were successful
Lint / lint (push) Successful in 13s
Test build / test-build (pull_request) Successful in 15s
2025-03-24 19:35:56 +01:00
Julien Valverdé
a0928c718f Version bump
All checks were successful
Lint / lint (push) Successful in 13s
Test build / test-build (pull_request) Successful in 15s
2025-03-24 19:33:35 +01:00
Julien Valverdé
49d9edd4b1 Dependencies upgrade
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-24 19:29:12 +01:00
Julien Valverdé
3552c25b5c Mutation refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-24 19:07:11 +01:00
Julien Valverdé
516e0a465d Ref state fix
All checks were successful
Lint / lint (push) Successful in 16s
2025-03-24 18:38:14 +01:00
Julien Valverdé
7cf5367409 Tests
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-24 17:34:50 +01:00
Julien Valverdé
3b237c0588 Query refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-24 17:30:41 +01:00
Julien Valverdé
d9aa42d23a Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-24 12:16:03 +01:00
Julien Valverdé
fd3213c53f Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-24 12:06:03 +01:00
Julien Valverdé
baa8c92221 Query refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-24 12:03:55 +01:00
Julien Valverdé
d55b432846 Refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-23 23:58:05 +01:00
Julien Valverdé
6266c7506e Example fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-23 07:32:11 +01:00
Julien Valverdé
043e966e45 ErrorHandler work
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-23 07:25:03 +01:00
Julien Valverdé
88fab2c7d7 ErrorHandler refactoring
Some checks failed
Lint / lint (push) Failing after 15s
2025-03-23 06:08:35 +01:00
Julien Valverdé
224ccd8e32 Fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-21 04:55:38 +01:00
Julien Valverdé
4cf70ada0b Fix
All checks were successful
Lint / lint (push) Successful in 16s
2025-03-21 04:49:44 +01:00
Julien Valverdé
f9bd5d4d6b Query refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-21 04:37:32 +01:00
Julien Valverdé
1ec1db0658 Mutation progress
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-21 03:38:48 +01:00
Julien Valverdé
2d94e84941 Stream fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-21 03:24:55 +01:00
Julien Valverdé
aab83907ba Working mutation progress
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-21 02:14:36 +01:00
Julien Valverdé
8c0d6b4c8a Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-21 01:24:52 +01:00
Julien Valverdé
d82d1d1c29 Refactoring
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-21 01:23:47 +01:00
Julien Valverdé
0f09573948 Mutation services
Some checks failed
Lint / lint (push) Failing after 14s
2025-03-20 07:10:55 +01:00
Julien Valverdé
2b6b36713e MutationRunner work
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-20 04:31:38 +01:00
Julien Valverdé
5d0aecc9d5 QueryProgress
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-19 05:13:54 +01:00
Julien Valverdé
f21d8b2d8a QueryProgress
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-18 03:11:39 +01:00
Julien Valverdé
f85173fa68 Fix
All checks were successful
Lint / lint (push) Successful in 30s
2025-03-18 02:46:41 +01:00
Julien Valverdé
65a124de1f Mutation tests
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-17 05:52:13 +01:00
Julien Valverdé
16893761c6 Mutation refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-17 05:34:19 +01:00
Julien Valverdé
3fdc2e31eb Mutation example
All checks were successful
Lint / lint (push) Successful in 17s
2025-03-17 02:36:13 +01:00
Julien Valverdé
8636a28f2f Working mutations
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-17 02:15:27 +01:00
Julien Valverdé
d56578da8f useMutation
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 06:50:20 +01:00
Julien Valverdé
299109d421 Mutation fix
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-16 06:25:02 +01:00
Julien Valverdé
4995b2949f MutationRunner
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 05:20:55 +01:00
Julien Valverdé
6e6e675709 MutationRunner 2025-03-16 05:20:37 +01:00
Julien Valverdé
b04860aa25 Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 04:32:51 +01:00
Julien Valverdé
e9e17ac211 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-16 04:11:25 +01:00
Julien Valverdé
1f0ff725ff Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 04:05:39 +01:00
Julien Valverdé
447d89982c Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 03:34:54 +01:00
Julien Valverdé
778ee27795 ErrorHandler refactoring
All checks were successful
Lint / lint (push) Successful in 16s
2025-03-16 03:33:01 +01:00
Julien Valverdé
077816efb6 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 03:23:12 +01:00
Julien Valverdé
e4bacd1ca7 Working QueryClient refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 03:19:12 +01:00
Julien Valverdé
0e2c0db28f QueryClient refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-16 02:52:49 +01:00
Julien Valverdé
c943d81702 QueryClient.make
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-15 22:27:15 +01:00
Julien Valverdé
c2bc406a5f Fixed query error handler
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-15 06:43:47 +01:00
Julien Valverdé
4e778b6c95 VQueryErrorHandler
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-15 05:12:38 +01:00
Julien Valverdé
0437fa5dcc QueryErrorHandler work
All checks were successful
Lint / lint (push) Successful in 16s
2025-03-15 02:30:37 +01:00
Julien Valverdé
5614b8df38 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-15 00:52:00 +01:00
Julien Valverdé
70b6c4434e Tests
All checks were successful
Lint / lint (push) Successful in 16s
2025-03-14 22:07:53 +01:00
Julien Valverdé
2e8dfbc988 QueryClient
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-14 22:00:53 +01:00
Julien Valverdé
abc47c4647 Fix
Some checks failed
Lint / lint (push) Failing after 12s
2025-03-14 05:04:49 +01:00
Julien Valverdé
eedd2a7f2a makeTag
Some checks failed
Lint / lint (push) Failing after 12s
2025-03-14 04:57:07 +01:00
Julien Valverdé
f4ab575a8d QueryExtension work
Some checks failed
Lint / lint (push) Failing after 13s
2025-03-14 04:24:56 +01:00
Julien Valverdé
747e2c6056 Done QueryClient
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-14 04:13:14 +01:00
Julien Valverdé
68c68417d8 QueryClient work
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-14 03:56:54 +01:00
Julien Valverdé
ed384a62a8 QueryClient work
Some checks failed
Lint / lint (push) Failing after 15s
2025-03-14 03:26:28 +01:00
Julien Valverdé
3a1748bb39 QueryClient tests
All checks were successful
Lint / lint (push) Successful in 18s
2025-03-13 22:31:50 +01:00
Julien Valverdé
66b8fd2c2e Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-12 06:37:39 +01:00
Julien Valverdé
bc81c443ab Query work
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-11 21:19:57 +01:00
Julien Valverdé
ee5dbe3766 Query work
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-11 20:39:56 +01:00
Julien Valverdé
825de84cef Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-11 03:12:36 +01:00
Julien Valverdé
d6011f7897 MutationRunner
Some checks failed
Lint / lint (push) Failing after 18s
2025-03-11 02:17:50 +01:00
Julien Valverdé
8d4bce9e53 Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-11 01:45:49 +01:00
Julien Valverdé
f7dd4e51f5 Doc update
All checks were successful
Lint / lint (push) Successful in 13s
Test build / test-build (pull_request) Successful in 16s
2025-03-11 01:36:13 +01:00
Julien Valverdé
8772e25ff5 CI update
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-10 18:44:08 +01:00
Julien Valverdé
94a0864132 Query refactoring
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-10 18:37:45 +01:00
Julien Valverdé
be8098fb7d Query work
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-10 01:56:11 +01:00
Julien Valverdé
7021e604ed Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-09 19:14:20 +01:00
Julien Valverdé
1fd2a9ffbe Cleanup
All checks were successful
Lint / lint (push) Successful in 17s
2025-03-09 18:35:48 +01:00
Julien Valverdé
1ed73dc3ac Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-09 18:21:35 +01:00
Julien Valverdé
c689778cea Working query
All checks were successful
Lint / lint (push) Successful in 15s
2025-03-09 18:08:52 +01:00
Julien Valverdé
da2a32001c Query work
Some checks failed
Lint / lint (push) Failing after 13s
2025-03-08 01:56:50 +01:00
Julien Valverdé
5ac3a932d9 Query work
Some checks failed
Lint / lint (push) Failing after 12s
2025-03-07 23:17:32 +01:00
Julien Valverdé
7935293bc3 Query work
All checks were successful
Lint / lint (push) Successful in 15s
2025-03-07 22:23:44 +01:00
Julien Valverdé
cabceaffcd Key work
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-07 04:26:39 +01:00
Julien Valverdé
d239a11cdc Service query
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-06 20:00:40 +01:00
Julien Valverdé
fad61afce7 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-06 17:32:30 +01:00
Julien Valverdé
11fd4941c0 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-06 17:26:08 +01:00
Julien Valverdé
7bebc39a87 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-06 17:22:27 +01:00
Julien Valverdé
3bc0cc6586 Cleanup
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-06 03:31:21 +01:00
Julien Valverdé
f99d18b846 Cleanup fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-06 03:15:43 +01:00
Julien Valverdé
d61339ea6a Query work
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-05 02:23:43 +01:00
Julien Valverdé
3659d3f342 Version bump
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-05 01:50:08 +01:00
Julien Valverdé
1e8a5d412f Refresh on window focus
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-05 00:44:13 +01:00
Julien Valverdé
86539f33f0 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-05 00:24:38 +01:00
Julien Valverdé
8fa24b1791 Query work
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-05 00:16:13 +01:00
Julien Valverdé
adaadf13b2 Working service query
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-04 23:18:35 +01:00
Julien Valverdé
3af7c3bf7a Query service work
Some checks failed
Lint / lint (push) Failing after 11s
2025-03-04 22:44:40 +01:00
Julien Valverdé
00b7228073 Refetch on focus
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-04 02:15:31 +01:00
Julien Valverdé
c2b2b1b96e Dependencies fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-04 02:04:29 +01:00
Julien Valverdé
74cf37e3a3 Query example
All checks were successful
Lint / lint (push) Successful in 14s
2025-03-04 01:35:52 +01:00
Julien Valverdé
98091d4598 Refactoring
All checks were successful
Lint / lint (push) Successful in 12s
2025-03-04 01:22:51 +01:00
Julien Valverdé
b2f1626268 Working query
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-04 01:19:42 +01:00
Julien Valverdé
40e8bf6a1f Query work
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-03 19:42:33 +01:00
Julien Valverdé
9c96741c8e Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-03 03:37:39 +01:00
Julien Valverdé
3fa9b7d821 Working query
All checks were successful
Lint / lint (push) Successful in 13s
2025-03-02 20:14:45 +01:00
Julien Valverdé
6b0f2f33cb Query work
Some checks failed
Lint / lint (push) Failing after 13s
2025-03-02 02:48:19 +01:00
Julien Valverdé
2e00db5778 Query work
Some checks failed
Lint / lint (push) Failing after 43s
2025-03-02 01:11:18 +01:00
Julien Valverdé
660f32a171 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-02-28 17:24:40 +01:00
Julien Valverdé
3f2639fda1 Query work
All checks were successful
Lint / lint (push) Successful in 13s
2025-02-28 16:08:08 +01:00
Julien Valverdé
f76b3f333a Query work
All checks were successful
Lint / lint (push) Successful in 13s
2025-02-28 02:13:23 +01:00
Julien Valverdé
3b407c6b4f Query work
All checks were successful
Lint / lint (push) Successful in 17s
2025-02-28 01:06:11 +01:00
Julien Valverdé
b01b95a9d5 Query work
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-28 00:27:22 +01:00
Julien Valverdé
91b95ea6af useRefState refactpro
All checks were successful
Lint / lint (push) Successful in 13s
2025-02-27 18:32:57 +01:00
Julien Valverdé
7c99d1ff3d Working useQuery
All checks were successful
Lint / lint (push) Successful in 13s
2025-02-27 01:19:09 +01:00
Julien Valverdé
ae815553f2 Query work
All checks were successful
Lint / lint (push) Successful in 13s
2025-02-26 23:57:03 +01:00
Julien Valverdé
86a96cbcce extension-query
Some checks failed
Lint / lint (push) Failing after 7s
2025-02-26 21:17:09 +01:00
Julien Valverdé
538b3a415d Cleanup
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-26 20:50:05 +01:00
Julien Valverdé
5b023678f4 Merge branch 'master' into next
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-26 20:47:00 +01:00
Julien Valverdé
9266697aa4 Merge branch 'next' of git.valverde.cloud:Thilawyn/reffuse into next
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-26 19:29:48 +01:00
Julien Valverdé
ad81bf9ed8 Cleanup
All checks were successful
Lint / lint (push) Successful in 11s
Test build / test-build (pull_request) Successful in 13s
2025-02-26 19:25:21 +01:00
Julien Valverdé
e92087e593 Turbo fix
All checks were successful
Lint / lint (push) Successful in 12s
Test build / test-build (pull_request) Successful in 13s
2025-02-26 19:23:49 +01:00
Julien Valverdé
e182e6ab5c README update
Some checks failed
Lint / lint (push) Successful in 12s
Test build / test-build (pull_request) Failing after 15s
2025-02-26 19:13:49 +01:00
Julien Valverdé
89175be558 README work
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-26 14:30:59 +01:00
Julien Valverdé
4df90a0f1c README work
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-26 14:05:12 +01:00
Julien Valverdé
693c7b2db8 Reffuse context refactoring
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-26 13:40:52 +01:00
Julien Valverdé
5f60d03d83 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-25 23:19:44 +01:00
Julien Valverdé
ea768218a0 Deps API change
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-25 23:11:58 +01:00
Julien Valverdé
3b4eb750ed Version bump
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-25 22:55:45 +01:00
Julien Valverdé
47aa130486 CI fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-25 22:53:07 +01:00
Julien Valverdé
02da3df8eb CI fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-25 22:45:55 +01:00
Julien Valverdé
8d276d2fbf Dependencies
Some checks failed
Lint / lint (push) Failing after 8s
2025-02-25 22:16:53 +01:00
Julien Valverdé
af077d34aa Turbo setup
Some checks failed
Lint / lint (push) Failing after 13s
2025-02-25 22:07:18 +01:00
Julien Valverdé
618cee4028 Callback tests
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-25 18:39:19 +01:00
Julien Valverdé
8244c34d2a Callback helpers
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-25 18:29:00 +01:00
Julien Valverdé
523d835d00 Fix
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-25 17:14:07 +01:00
Julien Valverdé
15e96b8fa9 Merge branch 'plugins' of git.valverde.cloud:Thilawyn/reffuse into plugins
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-25 14:49:22 +01:00
Julien Valverdé
44de864713 API update 2025-02-25 14:48:58 +01:00
Julien Valverdé
8e1f0a27cf Lockfile
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-25 13:45:09 +01:00
Julien Valverdé
8754020323 Working lazyref extension
Some checks failed
Lint / lint (push) Failing after 12s
2025-02-25 12:17:45 +01:00
Julien Valverdé
d9a01dae0f withLazyRef
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-25 11:22:49 +01:00
Julien Valverdé
8873e81f7c Dependencies
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-25 10:31:43 +01:00
Julien Valverdé
38fcafb15c Dependencies
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-25 10:21:34 +01:00
Julien Valverdé
411397c7de Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-02-24 21:30:13 +01:00
Julien Valverdé
85e7b54962 extension-lazyref
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-24 21:24:38 +01:00
Julien Valverdé
ce3989ab77 Extension fix
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-24 21:09:44 +01:00
Julien Valverdé
da0f6168f0 Fix
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-24 20:47:49 +01:00
Julien Valverdé
690dec1f1a Finalized
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-24 20:18:56 +01:00
Julien Valverdé
60274266da Extension work
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-24 20:00:02 +01:00
Julien Valverdé
28424b63cb Working extension
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-24 13:47:29 +01:00
Julien Valverdé
e063eb06f7 Extension work
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-24 13:17:10 +01:00
Julien Valverdé
fb5bb7fcef Cleanup
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-24 02:21:37 +01:00
Julien Valverdé
1f57f7d127 Tests
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-24 01:55:47 +01:00
Julien Valverdé
e8742e5aa6 Fix
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-23 23:38:24 +01:00
Julien Valverdé
be79d24d6e Tests
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-22 01:03:15 +01:00
Julien Valverdé
e1349e5e03 Tests
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-21 15:44:28 +01:00
Julien Valverdé
837dcbb1cb Extension work
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-21 15:27:11 +01:00
Julien Valverdé
8252b6cbdf Extension work
Some checks failed
Lint / lint (push) Failing after 10s
2025-02-21 05:22:19 +01:00
Julien Valverdé
256638bc06 ReffuseHelper
Some checks failed
Lint / lint (push) Failing after 11s
2025-02-21 04:22:48 +01:00
Julien Valverdé
c0097bbe81 Extension tests
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-20 14:57:46 +01:00
Julien Valverdé
febeaa05d0 ReffuseExtension
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-20 14:12:56 +01:00
Julien Valverdé
a71640d493 Cleanup
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-20 00:41:37 +01:00
Julien Valverdé
b636a709f3 Tests
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-20 00:39:15 +01:00
Julien Valverdé
fffbd01b5e Pipeable API tests
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-20 00:21:43 +01:00
Julien Valverdé
36d5414d10 Fix
All checks were successful
Lint / lint (push) Successful in 44s
2025-02-19 23:59:34 +01:00
Julien Valverdé
65810a6d79 usePromise
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-19 23:44:02 +01:00
Julien Valverdé
9e7b30fbb4 useFork refactoring
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-19 23:24:15 +01:00
Julien Valverdé
6c843562ab usePromiseScoped fork implementation
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-18 23:47:32 +01:00
Julien Valverdé
809f512d11 Fix
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-18 22:33:49 +01:00
Julien Valverdé
e71239b903 usePromiseScoped
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-18 22:28:49 +01:00
Julien Valverdé
bfcc097882 usePromise
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-18 15:25:46 +01:00
Julien Valverdé
933b061b5d Promise tests
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-18 05:18:34 +01:00
Julien Valverdé
734c84824c Implement Pipeable
All checks were successful
Lint / lint (push) Successful in 10s
2025-02-18 04:30:10 +01:00
Julien Valverdé
e83e86f8f1 Promise tests
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-18 02:56:05 +01:00
Julien Valverdé
bebbc1d7de Promise tests
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-18 02:23:40 +01:00
Julien Valverdé
a7a0951b61 Dependencies fix
All checks were successful
Lint / lint (push) Successful in 11s
2025-02-18 01:08:26 +01:00
Julien Valverdé
1b1a1961bc Dependencies upgrade
Some checks failed
Lint / lint (push) Failing after 13s
2025-02-17 00:16:41 +01:00
43 changed files with 900 additions and 1069 deletions

544
bun.lock

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@reffuse/monorepo",
"packageManager": "bun@1.2.13",
"packageManager": "bun@1.2.9",
"private": true,
"workspaces": [
"./packages/*"
@@ -15,9 +15,9 @@
"clean:node": "rm -rf node_modules"
},
"devDependencies": {
"npm-check-updates": "^18.0.1",
"npm-check-updates": "^17.1.18",
"npm-sort": "^0.0.4",
"turbo": "^2.5.3",
"turbo": "^2.5.0",
"typescript": "^5.8.3"
}
}

View File

@@ -11,41 +11,41 @@
"preview": "vite preview"
},
"devDependencies": {
"@eslint/js": "^9.26.0",
"@tanstack/react-router": "^1.120.3",
"@tanstack/react-router-devtools": "^1.120.3",
"@tanstack/router-plugin": "^1.120.3",
"@eslint/js": "^9.24.0",
"@tanstack/react-router": "^1.115.3",
"@tanstack/react-router-devtools": "^1.115.3",
"@tanstack/router-plugin": "^1.115.3",
"@thilawyn/thilaschema": "^0.1.4",
"@types/react": "^19.1.4",
"@types/react-dom": "^19.1.5",
"@vitejs/plugin-react": "^4.4.1",
"eslint": "^9.26.0",
"@types/react": "^19.1.1",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.24.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.1.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"typescript-eslint": "^8.32.1",
"vite": "^6.3.5"
"typescript-eslint": "^8.29.1",
"vite": "^6.2.6"
},
"dependencies": {
"@effect/platform": "^0.82.1",
"@effect/platform-browser": "^0.62.1",
"@effect/platform": "^0.80.8",
"@effect/platform-browser": "^0.59.8",
"@radix-ui/themes": "^3.2.1",
"@reffuse/extension-lazyref": "workspace:*",
"@reffuse/extension-query": "workspace:*",
"@typed/async-data": "^0.13.1",
"@typed/id": "^0.17.2",
"@typed/lazy-ref": "^0.3.3",
"effect": "^3.15.1",
"lucide-react": "^0.510.0",
"effect": "^3.14.8",
"lucide-react": "^0.487.0",
"mobx": "^6.13.7",
"reffuse": "workspace:*"
},
"overrides": {
"effect": "^3.15.1",
"@effect/platform": "^0.82.1",
"@effect/platform-browser": "^0.62.1",
"effect": "^3.14.8",
"@effect/platform": "^0.80.8",
"@effect/platform-browser": "^0.59.8",
"@typed/lazy-ref": "^0.3.3",
"@typed/async-data": "^0.13.1"
}

View File

@@ -1,15 +1,15 @@
import { AlertDialog, Button, Flex, Text } from "@radix-ui/themes"
import { Cause, Console, Effect, Either, flow, Match, Option, Stream } from "effect"
import { useState } from "react"
import { AppQueryErrorHandler } from "./query"
import { R } from "./reffuse"
import { AppQueryErrorHandler } from "./services"
export function VQueryErrorHandler() {
const [open, setOpen] = useState(false)
const error = R.useSubscribeStream(
R.useMemo(() => AppQueryErrorHandler.AppQueryErrorHandler.pipe(
R.useMemo(() => AppQueryErrorHandler.pipe(
Effect.map(handler => handler.errors.pipe(
Stream.changes,
Stream.tap(Console.error),

View File

@@ -1,5 +1,6 @@
import { ThSchema } from "@thilawyn/thilaschema"
import { Schema } from "effect"
import { GetRandomValues, makeUuid4 } from "@typed/id"
import { Effect, Schema } from "effect"
export class Todo extends Schema.Class<Todo>("Todo")({
@@ -17,4 +18,9 @@ export const TodoFromJsonStruct = Schema.Struct({
ThSchema.assertEncodedJsonifiable
)
export const TodoFromJson = Schema.compose(TodoFromJsonStruct, Todo)
export const TodoFromJson = TodoFromJsonStruct.pipe(Schema.compose(Todo))
export const generateUniqueID = makeUuid4.pipe(
Effect.provide(GetRandomValues.CryptoRandom)
)

View File

@@ -5,14 +5,14 @@ import { Layer } from "effect"
import { StrictMode } from "react"
import { createRoot } from "react-dom/client"
import { ReffuseRuntime } from "reffuse"
import { AppQueryClient, AppQueryErrorHandler } from "./query"
import { RootContext } from "./reffuse"
import { routeTree } from "./routeTree.gen"
import { AppQueryClient, AppQueryErrorHandler } from "./services"
const layer = Layer.empty.pipe(
Layer.provideMerge(AppQueryClient.AppQueryClient.Default),
Layer.provideMerge(AppQueryErrorHandler.AppQueryErrorHandler.Default),
Layer.provideMerge(AppQueryClient.Live),
Layer.provideMerge(AppQueryErrorHandler.Live),
Layer.provideMerge(Clipboard.layer),
Layer.provideMerge(Geolocation.layer),
Layer.provideMerge(Permissions.layer),

View File

@@ -0,0 +1,21 @@
import { HttpClientError } from "@effect/platform"
import { QueryClient, QueryErrorHandler } from "@reffuse/extension-query"
import { Effect } from "effect"
export class AppQueryErrorHandler extends QueryErrorHandler.Service<AppQueryErrorHandler,
HttpClientError.HttpClientError
>()(
"AppQueryErrorHandler",
(self, failure, defect) => self.pipe(
Effect.catchTags({
RequestError: failure,
ResponseError: failure,
}),
Effect.catchAllDefect(defect),
),
) {}
export class AppQueryClient extends QueryClient.Service<AppQueryClient>()({ ErrorHandler: AppQueryErrorHandler }) {}

View File

@@ -1,10 +1,10 @@
import { QueryRunner } from "@reffuse/extension-query"
import { QueryService } from "@reffuse/extension-query"
import { ParseResult, Schema } from "effect"
export const Result = Schema.Array(Schema.String)
export class Uuid4Query extends QueryRunner.Tag("Uuid4Query")<Uuid4Query,
export class Uuid4Query extends QueryService.Tag("Uuid4Query")<Uuid4Query,
readonly ["uuid4", number],
typeof Result.Type,
ParseResult.ParseError

View File

@@ -8,7 +8,7 @@ export function Uuid4QueryService() {
const runFork = R.useRunFork()
const query = R.useMemo(() => Uuid4Query.Uuid4Query, [])
const [state] = R.useSubscribeRefs(query.stateRef)
const [state] = R.useRefState(query.state)
return (

View File

@@ -3,12 +3,12 @@ import { Clipboard, Geolocation, Permissions } from "@effect/platform-browser"
import { LazyRefExtension } from "@reffuse/extension-lazyref"
import { QueryExtension } from "@reffuse/extension-query"
import { Reffuse, ReffuseContext } from "reffuse"
import { AppQueryClient, AppQueryErrorHandler } from "./services"
import { AppQueryClient, AppQueryErrorHandler } from "./query"
export const RootContext = ReffuseContext.make<
| AppQueryClient.AppQueryClient
| AppQueryErrorHandler.AppQueryErrorHandler
| AppQueryClient
| AppQueryErrorHandler
| Clipboard.Clipboard
| Geolocation.Geolocation
| Permissions.Permissions

View File

@@ -19,7 +19,6 @@ import { Route as LazyrefImport } from './routes/lazyref'
import { Route as CountImport } from './routes/count'
import { Route as BlankImport } from './routes/blank'
import { Route as IndexImport } from './routes/index'
import { Route as StreamsPullImport } from './routes/streams/pull'
import { Route as QueryUsequeryImport } from './routes/query/usequery'
import { Route as QueryUsemutationImport } from './routes/query/usemutation'
import { Route as QueryServiceImport } from './routes/query/service'
@@ -74,12 +73,6 @@ const IndexRoute = IndexImport.update({
getParentRoute: () => rootRoute,
} as any)
const StreamsPullRoute = StreamsPullImport.update({
id: '/streams/pull',
path: '/streams/pull',
getParentRoute: () => rootRoute,
} as any)
const QueryUsequeryRoute = QueryUsequeryImport.update({
id: '/query/usequery',
path: '/query/usequery',
@@ -179,13 +172,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof QueryUsequeryImport
parentRoute: typeof rootRoute
}
'/streams/pull': {
id: '/streams/pull'
path: '/streams/pull'
fullPath: '/streams/pull'
preLoaderRoute: typeof StreamsPullImport
parentRoute: typeof rootRoute
}
}
}
@@ -203,7 +189,6 @@ export interface FileRoutesByFullPath {
'/query/service': typeof QueryServiceRoute
'/query/usemutation': typeof QueryUsemutationRoute
'/query/usequery': typeof QueryUsequeryRoute
'/streams/pull': typeof StreamsPullRoute
}
export interface FileRoutesByTo {
@@ -218,7 +203,6 @@ export interface FileRoutesByTo {
'/query/service': typeof QueryServiceRoute
'/query/usemutation': typeof QueryUsemutationRoute
'/query/usequery': typeof QueryUsequeryRoute
'/streams/pull': typeof StreamsPullRoute
}
export interface FileRoutesById {
@@ -234,7 +218,6 @@ export interface FileRoutesById {
'/query/service': typeof QueryServiceRoute
'/query/usemutation': typeof QueryUsemutationRoute
'/query/usequery': typeof QueryUsequeryRoute
'/streams/pull': typeof StreamsPullRoute
}
export interface FileRouteTypes {
@@ -251,7 +234,6 @@ export interface FileRouteTypes {
| '/query/service'
| '/query/usemutation'
| '/query/usequery'
| '/streams/pull'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
@@ -265,7 +247,6 @@ export interface FileRouteTypes {
| '/query/service'
| '/query/usemutation'
| '/query/usequery'
| '/streams/pull'
id:
| '__root__'
| '/'
@@ -279,7 +260,6 @@ export interface FileRouteTypes {
| '/query/service'
| '/query/usemutation'
| '/query/usequery'
| '/streams/pull'
fileRoutesById: FileRoutesById
}
@@ -295,7 +275,6 @@ export interface RootRouteChildren {
QueryServiceRoute: typeof QueryServiceRoute
QueryUsemutationRoute: typeof QueryUsemutationRoute
QueryUsequeryRoute: typeof QueryUsequeryRoute
StreamsPullRoute: typeof StreamsPullRoute
}
const rootRouteChildren: RootRouteChildren = {
@@ -310,7 +289,6 @@ const rootRouteChildren: RootRouteChildren = {
QueryServiceRoute: QueryServiceRoute,
QueryUsemutationRoute: QueryUsemutationRoute,
QueryUsequeryRoute: QueryUsequeryRoute,
StreamsPullRoute: StreamsPullRoute,
}
export const routeTree = rootRoute
@@ -333,8 +311,7 @@ export const routeTree = rootRoute
"/todos",
"/query/service",
"/query/usemutation",
"/query/usequery",
"/streams/pull"
"/query/usequery"
]
},
"/": {
@@ -369,9 +346,6 @@ export const routeTree = rootRoute
},
"/query/usequery": {
"filePath": "query/usequery.tsx"
},
"/streams/pull": {
"filePath": "streams/pull.tsx"
}
}
}

View File

@@ -1,6 +1,6 @@
import { R } from "@/reffuse"
import { createFileRoute } from "@tanstack/react-router"
import { Effect, Ref } from "effect"
import { Ref } from "effect"
export const Route = createFileRoute("/count")({
@@ -11,13 +11,14 @@ function Count() {
const runSync = R.useRunSync()
const countRef = R.useRef(() => Effect.succeed(0))
const [count] = R.useSubscribeRefs(countRef)
const countRef = R.useRef(0)
const [count] = R.useRefState(countRef)
return (
<div className="container mx-auto">
<button onClick={() => runSync(Ref.update(countRef, count => count + 1))}>
{/* <button onClick={() => setCount((count) => count + 1)}> */}
<button onClick={() => Ref.update(countRef, count => count + 1).pipe(runSync)}>
count is {count}
</button>
</div>

View File

@@ -4,7 +4,7 @@ import { Uuid4QueryService } from "@/query/views/Uuid4QueryService"
import { R } from "@/reffuse"
import { HttpClient } from "@effect/platform"
import { createFileRoute } from "@tanstack/react-router"
import { Console, Effect, Layer, Schema } from "effect"
import { Console, Effect, Schema } from "effect"
import { useMemo } from "react"
@@ -14,21 +14,18 @@ export const Route = createFileRoute("/query/service")({
function RouteComponent() {
const query = R.useQuery({
key: R.useStreamFromReactiveValues(["uuid4", 10 as number]),
key: R.useStreamFromValues(["uuid4", 10 as number]),
query: ([, count]) => Console.log(`Querying ${ count } IDs...`).pipe(
Effect.andThen(Effect.sleep("500 millis")),
Effect.andThen(Effect.map(
HttpClient.HttpClient,
HttpClient.withTracerPropagation(false),
)),
Effect.flatMap(client => client.get(`https://www.uuidtools.com/api/generate/v4/count/${ count }`)),
Effect.andThen(HttpClient.get(`https://www.uuidtools.com/api/generate/v4/count/${ count }`)),
HttpClient.withTracerPropagation(false),
Effect.flatMap(res => res.json),
Effect.flatMap(Schema.decodeUnknown(Uuid4Query.Result)),
Effect.scoped,
),
})
const layer = useMemo(() => Layer.succeed(Uuid4Query.Uuid4Query, query), [query])
const layer = useMemo(() => query.layer(Uuid4Query.Uuid4Query), [query])
return (
<QueryContext.Provider layer={layer}>

View File

@@ -29,18 +29,15 @@ function RouteComponent() {
Effect.tap(() => QueryProgress.QueryProgress.update(() =>
AsyncData.Progress.make({ loaded: 50, total: Option.some(100) })
)),
Effect.andThen(Effect.map(
HttpClient.HttpClient,
HttpClient.withTracerPropagation(false),
)),
Effect.flatMap(client => client.get(`https://www.uuidtools.com/api/generate/v4/count/${ count }`)),
Effect.andThen(HttpClient.get(`https://www.uuidtools.com/api/generate/v4/count/${ count }`)),
HttpClient.withTracerPropagation(false),
Effect.flatMap(res => res.json),
Effect.flatMap(Schema.decodeUnknown(Result)),
Effect.scoped,
)
})
const [state] = R.useSubscribeRefs(mutation.stateRef)
const [state] = R.useSubscribeRefs(mutation.state)
return (

View File

@@ -20,21 +20,18 @@ function RouteComponent() {
const [count, setCount] = useState(1)
const query = R.useQuery({
key: R.useStreamFromReactiveValues(["uuid4", count]),
key: R.useStreamFromValues(["uuid4", count]),
query: ([, count]) => Console.log(`Querying ${ count } IDs...`).pipe(
Effect.andThen(Effect.sleep("500 millis")),
Effect.andThen(Effect.map(
HttpClient.HttpClient,
HttpClient.withTracerPropagation(false),
)),
Effect.flatMap(client => client.get(`https://www.uuidtools.com/api/generate/v4/count/${ count }`)),
Effect.andThen(HttpClient.get(`https://www.uuidtools.com/api/generate/v4/count/${ count }`)),
HttpClient.withTracerPropagation(false),
Effect.flatMap(res => res.json),
Effect.flatMap(Schema.decodeUnknown(Result)),
Effect.scoped,
),
})
const [state] = R.useSubscribeRefs(query.stateRef)
const [state] = R.useSubscribeRefs(query.state)
return (

View File

@@ -1,34 +0,0 @@
import { R } from "@/reffuse"
import { Button, Flex, Text } from "@radix-ui/themes"
import { createFileRoute } from "@tanstack/react-router"
import { Chunk, Effect, Exit, Option, Queue, Random, Scope, Stream } from "effect"
import { useMemo, useState } from "react"
export const Route = createFileRoute("/streams/pull")({
component: RouteComponent
})
function RouteComponent() {
const stream = useMemo(() => Stream.repeatEffect(Random.nextInt), [])
const streamScope = R.useScope([stream], { finalizerExecutionMode: "fork" })
const queue = R.useMemo(() => Effect.provideService(Stream.toQueueOfElements(stream), Scope.Scope, streamScope), [streamScope])
const [value, setValue] = useState(Option.none<number>())
const pullLatest = R.useCallbackSync(() => Queue.takeAll(queue).pipe(
Effect.flatMap(Chunk.last),
Effect.flatMap(Exit.matchEffect({
onSuccess: Effect.succeed,
onFailure: Effect.fail,
})),
Effect.tap(v => Effect.sync(() => setValue(Option.some(v)))),
), [queue])
return (
<Flex direction="column" align="center" gap="2">
{Option.isSome(value) && <Text>{value.value}</Text>}
<Button onClick={pullLatest}>Pull latest</Button>
</Flex>
)
}

View File

@@ -2,21 +2,7 @@ import { R } from "@/reffuse"
import { Button, Flex, Text } from "@radix-ui/themes"
import { createFileRoute } from "@tanstack/react-router"
import { GetRandomValues, makeUuid4 } from "@typed/id"
import { Console, Effect, Option } from "effect"
import { useEffect, useState } from "react"
interface Node {
value: string
left?: Leaf
right?: Leaf
}
interface Leaf {
node: Node
}
const makeUuid = Effect.provide(makeUuid4, GetRandomValues.CryptoRandom)
import { Console, Effect, Ref } from "effect"
export const Route = createFileRoute("/tests")({
@@ -24,39 +10,48 @@ export const Route = createFileRoute("/tests")({
})
function RouteComponent() {
const runSync = R.useRunSync()
const deepRef = R.useRef({ value: "poulet" })
const deepValueRef = R.useSubRef(deepRef, ["value"])
const [uuid, setUuid] = useState(R.useMemo(() => makeUuid, []))
const generateUuid = R.useCallbackSync(() => makeUuid.pipe(
Effect.tap(v => Effect.sync(() => setUuid(v)))
// const value = R.useMemoScoped(Effect.addFinalizer(() => Console.log("cleanup")).pipe(
// Effect.andThen(makeUuid4),
// Effect.provide(GetRandomValues.CryptoRandom),
// ), [])
// console.log(value)
R.useFork(() => Effect.addFinalizer(() => Console.log("cleanup")).pipe(
Effect.andThen(Console.log("ouient")),
Effect.delay("1 second"),
), [])
const uuidStream = R.useStreamFromReactiveValues([uuid])
const uuidStreamLatestValue = R.useSubscribeStream(uuidStream)
const [, scopeLayer] = R.useScope([uuid])
useEffect(() => Effect.addFinalizer(() => Console.log("Scope cleanup!")).pipe(
Effect.andThen(Console.log("Scope changed")),
Effect.provide(scopeLayer),
runSync,
), [scopeLayer, runSync])
const uuidRef = R.useRef("none")
const anotherRef = R.useRef(69)
const nodeRef = R.useRef(() => Effect.succeed<Node>({ value: "prout" }))
const nodeValueRef = R.useSubRefFromPath(nodeRef, ["value"])
const logValue = R.useCallbackSync(Effect.fn(function*(value: string) {
yield* Effect.log(value)
}), [])
const generateUuid = R.useCallbackSync(() => makeUuid4.pipe(
Effect.provide(GetRandomValues.CryptoRandom),
Effect.tap(v => Ref.set(uuidRef, v)),
Effect.tap(v => Ref.set(deepValueRef, v)),
), [])
return (
<Flex direction="column" justify="center" align="center" gap="2">
<Text>{uuid}</Text>
<Button onClick={generateUuid}>Generate UUID</Button>
<Text>
{Option.match(uuidStreamLatestValue, {
onSome: ([v]) => v,
onNone: () => <></>,
})}
</Text>
<Flex direction="row" justify="center" align="center" gap="2">
<R.SubscribeRefs refs={[uuidRef, anotherRef]}>
{(uuid, anotherRef) => <Text>{uuid} / {anotherRef}</Text>}
</R.SubscribeRefs>
<R.SubscribeRefs refs={[deepRef, deepValueRef]}>
{(deep, deepValue) => <Text>{JSON.stringify(deep)} / {deepValue}</Text>}
</R.SubscribeRefs>
<Button onClick={() => logValue("test")}>Log value</Button>
<Button onClick={() => generateUuid()}>Generate UUID</Button>
</Flex>
)
}

View File

@@ -26,7 +26,7 @@ function Todos() {
return (
<Container>
<TodosContext.Provider layer={todosLayer} finalizerExecutionMode="fork">
<TodosContext.Provider layer={todosLayer}>
<VTodos />
</TodosContext.Provider>
</Container>

View File

@@ -1,7 +0,0 @@
import { QueryClient } from "@reffuse/extension-query"
import * as AppQueryErrorHandler from "./AppQueryErrorHandler"
export class AppQueryClient extends QueryClient.Service<AppQueryClient>()({
errorHandler: AppQueryErrorHandler.AppQueryErrorHandler
}) {}

View File

@@ -1,13 +0,0 @@
import { HttpClientError } from "@effect/platform"
import { QueryErrorHandler } from "@reffuse/extension-query"
import { Effect } from "effect"
export class AppQueryErrorHandler extends Effect.Service<AppQueryErrorHandler>()("AppQueryErrorHandler", {
effect: QueryErrorHandler.make<HttpClientError.HttpClientError>()(
(self, failure, defect) => self.pipe(
Effect.catchTag("RequestError", "ResponseError", failure),
Effect.catchAllDefect(defect),
)
)
}) {}

View File

@@ -1,2 +1 @@
export * as AppQueryClient from "./AppQueryClient"
export * as AppQueryErrorHandler from "./AppQueryErrorHandler"
export {}

View File

@@ -2,43 +2,68 @@ import { Todo } from "@/domain"
import { KeyValueStore } from "@effect/platform"
import { BrowserKeyValueStore } from "@effect/platform-browser"
import { PlatformError } from "@effect/platform/Error"
import { Chunk, Context, Effect, identity, Layer, ParseResult, Ref, Schema, Stream, SubscriptionRef } from "effect"
import { Chunk, Context, Effect, identity, Layer, ParseResult, Ref, Schema, SubscriptionRef } from "effect"
export class TodosState extends Context.Tag("TodosState")<TodosState, {
readonly todos: SubscriptionRef.SubscriptionRef<Chunk.Chunk<Todo.Todo>>
readonly load: Effect.Effect<void, PlatformError | ParseResult.ParseError>
readonly save: Effect.Effect<void, PlatformError | ParseResult.ParseError>
readonly readFromLocalStorage: Effect.Effect<void, PlatformError | ParseResult.ParseError>
readonly saveToLocalStorage: Effect.Effect<void, PlatformError | ParseResult.ParseError>
readonly prepend: (todo: Todo.Todo) => Effect.Effect<void>
readonly replace: (index: number, todo: Todo.Todo) => Effect.Effect<void>
readonly remove: (index: number) => Effect.Effect<void>
// readonly moveUp: (index: number) => Effect.Effect<void, Cause.NoSuchElementException>
// readonly moveDown: (index: number) => Effect.Effect<void, Cause.NoSuchElementException>
}>() {}
export const make = (key: string) => Layer.effect(TodosState, Effect.gen(function*() {
const todos = yield* SubscriptionRef.make(Chunk.empty<Todo.Todo>())
const readFromLocalStorage = KeyValueStore.KeyValueStore.pipe(
Effect.flatMap(kv => kv.get(key)),
Effect.flatMap(identity),
Effect.flatMap(Schema.decode(
Schema.compose(Schema.parseJson(), Schema.Chunk(Todo.TodoFromJson))
Effect.flatMap(Schema.parseJson().pipe(
Schema.compose(Schema.Chunk(Todo.TodoFromJson)),
Schema.decode,
)),
Effect.catchTag("NoSuchElementException", () => Effect.succeed(Chunk.empty<Todo.Todo>())),
Effect.flatMap(v => Ref.set(todos, v)),
Effect.catchTag("NoSuchElementException", () => Ref.set(todos, Chunk.empty())),
Effect.provide(BrowserKeyValueStore.layerLocalStorage),
)
const writeToLocalStorage = (values: Chunk.Chunk<Todo.Todo>) => KeyValueStore.KeyValueStore.pipe(
Effect.flatMap(kv => values.pipe(
Schema.encode(
Schema.compose(Schema.parseJson(), Schema.Chunk(Todo.TodoFromJson))
const saveToLocalStorage = Effect.all([KeyValueStore.KeyValueStore, todos]).pipe(
Effect.flatMap(([kv, values]) => values.pipe(
Schema.parseJson().pipe(
Schema.compose(Schema.Chunk(Todo.TodoFromJson)),
Schema.encode,
),
Effect.flatMap(v => kv.set(key, v)),
)),
Effect.provide(BrowserKeyValueStore.layerLocalStorage),
)
const todos = yield* SubscriptionRef.make(yield* readFromLocalStorage)
const load = Effect.flatMap(readFromLocalStorage, v => Ref.set(todos, v))
const save = Effect.flatMap(todos, writeToLocalStorage)
const prepend = (todo: Todo.Todo) => Ref.update(todos, Chunk.prepend(todo))
const replace = (index: number, todo: Todo.Todo) => Ref.update(todos, Chunk.replace(index, todo))
const remove = (index: number) => Ref.update(todos, Chunk.remove(index))
// Sync changes with local storage
yield* Effect.forkScoped(Stream.runForEach(todos.changes, writeToLocalStorage))
// const moveUp = (index: number) => Effect.gen(function*() {
return { todos, load, save }
// })
yield* readFromLocalStorage
return {
todos,
readFromLocalStorage,
saveToLocalStorage,
prepend,
replace,
remove,
}
}))

View File

@@ -1,27 +1,25 @@
import { Todo } from "@/domain"
import { Box, Button, Card, Flex, TextArea } from "@radix-ui/themes"
import { GetRandomValues, makeUuid4 } from "@typed/id"
import { Chunk, Effect, Option, Ref } from "effect"
import { Effect, Option, SubscriptionRef } from "effect"
import { R } from "../reffuse"
import { TodosState } from "../services"
const createEmptyTodo = makeUuid4.pipe(
Effect.map(id => Todo.Todo.make({ id, content: "", completedAt: Option.none()}, true)),
Effect.provide(GetRandomValues.CryptoRandom),
const createEmptyTodo = Todo.generateUniqueID.pipe(
Effect.map(id => Todo.Todo.make({
id,
content: "",
completedAt: Option.none(),
}, true))
)
export function VNewTodo() {
const todoRef = R.useRef(() => createEmptyTodo)
const [content, setContent] = R.useRefState(R.useSubRefFromPath(todoRef, ["content"]))
const runSync = R.useRunSync()
const add = R.useCallbackSync(() => Effect.all([TodosState.TodosState, todoRef]).pipe(
Effect.flatMap(([state, todo]) => Ref.update(state.todos, Chunk.prepend(todo))),
Effect.andThen(createEmptyTodo),
Effect.flatMap(v => Ref.set(todoRef, v)),
), [todoRef])
const todoRef = R.useMemo(() => createEmptyTodo.pipe(Effect.flatMap(SubscriptionRef.make)), [])
const [todo, setTodo] = R.useRefState(todoRef)
return (
@@ -29,12 +27,23 @@ export function VNewTodo() {
<Card>
<Flex direction="column" align="stretch" gap="2">
<TextArea
value={content}
onChange={e => setContent(e.target.value)}
value={todo.content}
onChange={e => setTodo(prev =>
Todo.Todo.make({ ...prev, content: e.target.value }, true)
)}
/>
<Flex direction="row" justify="center" align="center">
<Button onClick={add}>Add</Button>
<Button
onClick={() => TodosState.TodosState.pipe(
Effect.flatMap(state => state.prepend(todo)),
Effect.andThen(createEmptyTodo),
Effect.map(setTodo),
runSync,
)}
>
Add
</Button>
</Flex>
</Flex>
</Card>

View File

@@ -1,28 +1,20 @@
import { Todo } from "@/domain"
import { Box, Card, Flex, IconButton, TextArea } from "@radix-ui/themes"
import { Effect, Ref, Stream, SubscriptionRef } from "effect"
import { Effect } from "effect"
import { Delete } from "lucide-react"
import { useState } from "react"
import { R } from "../reffuse"
import { TodosState } from "../services"
export interface VTodoProps {
readonly todoRef: SubscriptionRef.SubscriptionRef<Todo.Todo>
readonly remove: Effect.Effect<void>
readonly index: number
readonly todo: Todo.Todo
}
export function VTodo({ todoRef, remove }: VTodoProps) {
export function VTodo({ index, todo }: VTodoProps) {
const runSync = R.useRunSync()
const localTodoRef = R.useRef(() => todoRef)
const [content, setContent] = R.useRefState(R.useSubRefFromPath(localTodoRef, ["content"]))
R.useFork(() => localTodoRef.changes.pipe(
Stream.debounce("250 millis"),
Stream.runForEach(v => Ref.set(todoRef, v)),
), [localTodoRef])
const editorMode = useState(false)
@@ -31,8 +23,14 @@ export function VTodo({ todoRef, remove }: VTodoProps) {
<Card>
<Flex direction="column" align="stretch" gap="1">
<TextArea
value={content}
onChange={e => setContent(e.target.value)}
value={todo.content}
onChange={e => TodosState.TodosState.pipe(
Effect.flatMap(state => state.replace(
index,
Todo.Todo.make({ ...todo, content: e.target.value }, true),
)),
runSync,
)}
disabled={!editorMode}
/>
@@ -40,7 +38,12 @@ export function VTodo({ todoRef, remove }: VTodoProps) {
<Box></Box>
<Flex direction="row" align="center" gap="1">
<IconButton onClick={() => runSync(remove)}>
<IconButton
onClick={() => TodosState.TodosState.pipe(
Effect.flatMap(state => state.remove(index)),
runSync,
)}
>
<Delete />
</IconButton>
</Flex>

View File

@@ -1,5 +1,5 @@
import { Box, Flex } from "@radix-ui/themes"
import { Chunk, Effect, Ref } from "effect"
import { Chunk, Effect, Stream } from "effect"
import { R } from "../reffuse"
import { TodosState } from "../services"
import { VNewTodo } from "./VNewTodo"
@@ -8,8 +8,15 @@ import { VTodo } from "./VTodo"
export function VTodos() {
const todosRef = R.useMemo(() => Effect.map(TodosState.TodosState, state => state.todos), [])
const [todos] = R.useSubscribeRefs(todosRef)
// Sync changes to the todos with the local storage
R.useFork(() => TodosState.TodosState.pipe(
Effect.flatMap(state =>
Stream.runForEach(state.todos.changes, () => state.saveToLocalStorage)
)
), [])
const todosRef = R.useMemo(() => TodosState.TodosState.pipe(Effect.map(state => state.todos)), [])
const [todos] = R.useRefState(todosRef)
return (
@@ -20,16 +27,7 @@ export function VTodos() {
{Chunk.map(todos, (todo, index) => (
<Box key={todo.id} width="500px">
<R.SubRefFromGetSet
parent={todosRef}
getter={parentValue => Chunk.unsafeGet(parentValue, index)}
setter={(parentValue, value) => Chunk.replace(parentValue, index, value)}
>
{ref => <VTodo
todoRef={ref}
remove={Ref.update(todosRef, Chunk.remove(index))}
/>}
</R.SubRefFromGetSet>
<VTodo index={index} todo={todo} />
</Box>
))}
</Flex>

View File

@@ -35,7 +35,7 @@
"peerDependencies": {
"@typed/lazy-ref": "^0.3.0",
"@types/react": "^19.0.0",
"effect": "^3.15.0",
"effect": "^3.13.0",
"react": "^19.0.0",
"reffuse": "^0.1.8"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@reffuse/extension-query",
"version": "0.1.5",
"version": "0.1.3",
"type": "module",
"files": [
"./README.md",
@@ -37,8 +37,8 @@
"@effect/platform-browser": "^0.56.0",
"@typed/async-data": "^0.13.0",
"@types/react": "^19.0.0",
"effect": "^3.15.0",
"effect": "^3.13.0",
"react": "^19.0.0",
"reffuse": "^0.1.11"
"reffuse": "^0.1.6"
}
}

View File

@@ -0,0 +1,16 @@
import type * as AsyncData from "@typed/async-data"
import { Effect, type Fiber, type Stream, type SubscriptionRef } from "effect"
export interface MutationService<K extends readonly unknown[], A, E> {
readonly state: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly mutate: (...key: K) => Effect.Effect<AsyncData.Success<A> | AsyncData.Failure<E>>
readonly forkMutate: (...key: K) => Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
}
export const Tag = <const Id extends string>(id: Id) => <
Self, K extends readonly unknown[], A, E = never,
>() => Effect.Tag(id)<Self, MutationService<K, A, E>>()

View File

@@ -1,4 +1,4 @@
import { Context, Effect, identity, Layer } from "effect"
import { Context, Effect, Layer } from "effect"
import type { Mutable } from "effect/Types"
import * as QueryErrorHandler from "./QueryErrorHandler.js"
@@ -8,17 +8,6 @@ export interface QueryClient<FallbackA, HandledE> {
}
export interface MakeProps<FallbackA, HandledE> {
readonly errorHandler: QueryErrorHandler.QueryErrorHandler<FallbackA, HandledE>
}
export const make = <FallbackA, HandledE>(
{ errorHandler }: MakeProps<FallbackA, HandledE>
): Effect.Effect<QueryClient<FallbackA, HandledE>> => Effect.Do.pipe(
Effect.let("errorHandler", () => errorHandler)
)
const id = "@reffuse/extension-query/QueryClient"
export type TagClassShape<FallbackA, HandledE> = Context.TagClassShape<typeof id, QueryClient<FallbackA, HandledE>>
@@ -30,28 +19,46 @@ export type GenericTagClass<FallbackA, HandledE> = Context.TagClass<
export const makeGenericTagClass = <FallbackA = never, HandledE = never>(): GenericTagClass<FallbackA, HandledE> => Context.Tag(id)()
export interface ServiceProps<FallbackA = never, HandledE = never, E = never, R = never> {
readonly errorHandler?: Effect.Effect<QueryErrorHandler.QueryErrorHandler<FallbackA, HandledE>, E, R>
export interface ServiceProps<EH, FallbackA, HandledE> {
readonly ErrorHandler?: Context.Tag<EH, QueryErrorHandler.QueryErrorHandler<FallbackA, HandledE>>
}
export interface ServiceResult<Self, FallbackA, HandledE, E, R> extends Context.TagClass<
export interface ServiceResult<Self, EH, FallbackA, HandledE> extends Context.TagClass<
Self,
typeof id,
QueryClient<FallbackA, HandledE>
> {
readonly Default: Layer.Layer<Self, E, R>
readonly Live: Layer.Layer<
Self | (EH extends QueryErrorHandler.DefaultQueryErrorHandler ? EH : never),
never,
EH extends QueryErrorHandler.DefaultQueryErrorHandler ? never : EH
>
}
export const Service = <Self>() => (
<FallbackA = never, HandledE = never, E = never, R = never>(
props?: ServiceProps<FallbackA, HandledE, E, R>
): ServiceResult<Self, FallbackA, HandledE, E, R> => {
const TagClass = Context.Tag(id)() as ServiceResult<Self, FallbackA, HandledE, E, R>
<
EH = QueryErrorHandler.DefaultQueryErrorHandler,
FallbackA = QueryErrorHandler.Fallback<Context.Tag.Service<QueryErrorHandler.DefaultQueryErrorHandler>>,
HandledE = QueryErrorHandler.Error<Context.Tag.Service<QueryErrorHandler.DefaultQueryErrorHandler>>,
>(
props?: ServiceProps<EH, FallbackA, HandledE>
): ServiceResult<Self, EH, FallbackA, HandledE> => {
const TagClass = Context.Tag(id)() as ServiceResult<Self, EH, FallbackA, HandledE>
(TagClass as Mutable<typeof TagClass>).Default = Layer.effect(TagClass, Effect.flatMap(
props?.errorHandler ?? QueryErrorHandler.make<never>()(identity),
errorHandler => make({ errorHandler }),
))
(TagClass as Mutable<typeof TagClass>).Live = Layer.effect(TagClass, Effect.Do.pipe(
Effect.bind("errorHandler", () =>
(props?.ErrorHandler ?? QueryErrorHandler.DefaultQueryErrorHandler) as Effect.Effect<
QueryErrorHandler.QueryErrorHandler<FallbackA, HandledE>,
never,
EH extends QueryErrorHandler.DefaultQueryErrorHandler ? never : EH
>
)
)).pipe(
Layer.provideMerge((props?.ErrorHandler
? Layer.empty
: QueryErrorHandler.DefaultQueryErrorHandler.Live
) as Layer.Layer<EH>)
)
return TagClass
}

View File

@@ -1,4 +1,5 @@
import { Cause, Effect, PubSub, Stream } from "effect"
import { Cause, Context, Effect, identity, Layer, Queue, Stream } from "effect"
import type { Mutable } from "effect/Types"
export interface QueryErrorHandler<FallbackA, HandledE> {
@@ -10,31 +11,55 @@ export type Fallback<T> = T extends QueryErrorHandler<infer A, any> ? A : never
export type Error<T> = T extends QueryErrorHandler<any, infer E> ? E : never
export const make = <HandledE = never>() => (
<FallbackA>(
export interface ServiceResult<
Self,
Id extends string,
FallbackA,
HandledE,
> extends Context.TagClass<
Self,
Id,
QueryErrorHandler<FallbackA, HandledE>
> {
readonly Live: Layer.Layer<Self>
}
export const Service = <Self, HandledE = never>() => (
<const Id extends string, FallbackA>(
id: Id,
f: (
self: Effect.Effect<never, HandledE>,
failure: (failure: HandledE) => Effect.Effect<never>,
defect: (defect: unknown) => Effect.Effect<never>,
) => Effect.Effect<FallbackA>
): Effect.Effect<QueryErrorHandler<FallbackA, HandledE>> => Effect.gen(function*() {
const pubsub = yield* PubSub.unbounded<Cause.Cause<HandledE>>()
const errors = Stream.fromPubSub(pubsub)
) => Effect.Effect<FallbackA>,
): ServiceResult<Self, Id, FallbackA, HandledE> => {
const TagClass = Context.Tag(id)() as ServiceResult<Self, Id, FallbackA, HandledE>
const handle = <A, E, R>(
self: Effect.Effect<A, E, R>
): Effect.Effect<A | FallbackA, Exclude<E, HandledE>, R> => f(
self as unknown as Effect.Effect<never, HandledE, never>,
(failure: HandledE) => Effect.andThen(
PubSub.publish(pubsub, Cause.fail(failure)),
Effect.failCause(Cause.empty),
),
(defect: unknown) => Effect.andThen(
PubSub.publish(pubsub, Cause.die(defect)),
Effect.failCause(Cause.empty),
),
)
(TagClass as Mutable<typeof TagClass>).Live = Layer.effect(TagClass, Effect.gen(function*() {
const queue = yield* Queue.unbounded<Cause.Cause<HandledE>>()
const errors = Stream.fromQueue(queue)
return { errors, handle }
})
const handle = <A, E, R>(
self: Effect.Effect<A, E, R>
): Effect.Effect<A | FallbackA, Exclude<E, HandledE>, R> => f(
self as unknown as Effect.Effect<never, HandledE, never>,
(failure: HandledE) => Queue.offer(queue, Cause.fail(failure)).pipe(
Effect.andThen(Effect.failCause(Cause.empty))
),
(defect: unknown) => Queue.offer(queue, Cause.die(defect)).pipe(
Effect.andThen(Effect.failCause(Cause.empty))
),
)
return { errors, handle }
}))
return TagClass
}
)
export class DefaultQueryErrorHandler extends Service<DefaultQueryErrorHandler>()(
"@reffuse/extension-query/DefaultQueryErrorHandler",
identity,
) {}

View File

@@ -1,21 +1,53 @@
import type { Effect, Stream } from "effect"
import type * as AsyncData from "@typed/async-data"
import { type Cause, type Context, Effect, type Fiber, Layer, type Option, type Stream, type SubscriptionRef } from "effect"
import * as React from "react"
import { ReffuseExtension, type ReffuseNamespace } from "reffuse"
import * as MutationRunner from "./MutationRunner.js"
import type * as MutationService from "./MutationService.js"
import * as QueryClient from "./QueryClient.js"
import type * as QueryProgress from "./QueryProgress.js"
import * as QueryRunner from "./QueryRunner.js"
import type * as QueryService from "./QueryService.js"
import { MutationRunner, QueryRunner } from "./internal/index.js"
export interface UseQueryProps<K extends readonly unknown[], A, E, R> {
readonly key: Stream.Stream<K>
readonly query: (key: K) => Effect.Effect<A, E, R | QueryProgress.QueryProgress>
readonly options?: QueryRunner.RunOptions
readonly refreshOnWindowFocus?: boolean
}
export interface UseQueryResult<K extends readonly unknown[], A, E> {
readonly latestKey: SubscriptionRef.SubscriptionRef<Option.Option<K>>
readonly state: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly forkRefresh: Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>, Cause.NoSuchElementException>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
readonly layer: <Self, Id extends string>(
tag: Context.TagClass<Self, Id, QueryService.QueryService<K, A, E>>
) => Layer.Layer<Self>
}
export interface UseMutationProps<K extends readonly unknown[], A, E, R> {
readonly mutation: (key: K) => Effect.Effect<A, E, R | QueryProgress.QueryProgress>
}
export interface UseMutationResult<K extends readonly unknown[], A, E> {
readonly state: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly mutate: (...key: K) => Effect.Effect<AsyncData.Success<A> | AsyncData.Failure<E>>
readonly forkMutate: (...key: K) => Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
readonly layer: <Self, Id extends string>(
tag: Context.TagClass<Self, Id, MutationService.MutationService<K, A, E>>
) => Layer.Layer<Self>
}
export const QueryExtension = ReffuseExtension.make(() => ({
useQuery<
@@ -29,16 +61,32 @@ export const QueryExtension = ReffuseExtension.make(() => ({
>(
this: ReffuseNamespace.ReffuseNamespace<R | QueryClient.TagClassShape<FallbackA, HandledE>>,
props: UseQueryProps<QK, QA, QE, QR>,
): QueryRunner.QueryRunner<QK, QA | FallbackA, Exclude<QE, HandledE>> {
): UseQueryResult<QK, QA | FallbackA, Exclude<QE, HandledE>> {
const runner = this.useMemo(() => QueryRunner.make({
QueryClient: QueryClient.makeGenericTagClass<FallbackA, HandledE>(),
key: props.key,
query: props.query,
}), [props.key])
this.useFork(() => QueryRunner.run(runner, props.options), [runner])
this.useFork(() => runner.fetchOnKeyChange, [runner])
return runner
this.useFork(() => (props.refreshOnWindowFocus ?? true)
? runner.refreshOnWindowFocus
: Effect.void,
[props.refreshOnWindowFocus, runner])
return React.useMemo(() => ({
latestKey: runner.latestKeyRef,
state: runner.stateRef,
forkRefresh: runner.forkRefresh,
layer: tag => Layer.succeed(tag, {
latestKey: runner.latestKeyRef,
state: runner.stateRef,
forkRefresh: runner.forkRefresh,
}),
}), [runner])
},
useMutation<
@@ -52,10 +100,23 @@ export const QueryExtension = ReffuseExtension.make(() => ({
>(
this: ReffuseNamespace.ReffuseNamespace<R | QueryClient.TagClassShape<FallbackA, HandledE>>,
props: UseMutationProps<QK, QA, QE, QR>,
): MutationRunner.MutationRunner<QK, QA | FallbackA, Exclude<QE, HandledE>> {
return this.useMemo(() => MutationRunner.make({
): UseMutationResult<QK, QA | FallbackA, Exclude<QE, HandledE>> {
const runner = this.useMemo(() => MutationRunner.make({
QueryClient: QueryClient.makeGenericTagClass<FallbackA, HandledE>(),
mutation: props.mutation,
}), [])
return React.useMemo(() => ({
state: runner.stateRef,
mutate: runner.mutate,
forkMutate: runner.forkMutate,
layer: tag => Layer.succeed(tag, {
state: runner.stateRef,
mutate: runner.mutate,
forkMutate: runner.forkMutate,
}),
}), [runner])
},
}))

View File

@@ -10,7 +10,7 @@ export class QueryProgress extends Effect.Tag("@reffuse/extension-query/QueryPro
f: (previous: Option.Option<AsyncData.Progress>) => AsyncData.Progress
) => Effect.Effect<void>
}>() {
static readonly Default: Layer.Layer<
static readonly Live: Layer.Layer<
QueryProgress,
never,
QueryState.QueryState<any, any>

View File

@@ -1,193 +0,0 @@
import { BrowserStream } from "@effect/platform-browser"
import * as AsyncData from "@typed/async-data"
import { type Cause, Effect, Fiber, identity, Option, Queue, Ref, type Scope, Stream, SubscriptionRef } from "effect"
import type * as QueryClient from "./QueryClient.js"
import * as QueryProgress from "./QueryProgress.js"
import { QueryState } from "./internal/index.js"
export interface QueryRunner<K extends readonly unknown[], A, E> {
readonly queryKey: Stream.Stream<K>
readonly latestKeyValueRef: SubscriptionRef.SubscriptionRef<Option.Option<K>>
readonly stateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly fiberRef: SubscriptionRef.SubscriptionRef<Option.Option<Fiber.RuntimeFiber<
AsyncData.Success<A> | AsyncData.Failure<E>,
Cause.NoSuchElementException
>>>
readonly interrupt: Effect.Effect<void>
readonly forkInterrupt: Effect.Effect<Fiber.RuntimeFiber<void>>
readonly forkFetch: (keyValue: K) => Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
readonly forkRefresh: Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>, Cause.NoSuchElementException>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
}
export const Tag = <const Id extends string>(id: Id) => <
Self, K extends readonly unknown[], A, E = never
>() => Effect.Tag(id)<Self, QueryRunner<K, A, E>>()
export interface MakeProps<K extends readonly unknown[], A, FallbackA, E, HandledE, R> {
readonly QueryClient: QueryClient.GenericTagClass<FallbackA, HandledE>
readonly key: Stream.Stream<K>
readonly query: (key: K) => Effect.Effect<A, E, R | QueryProgress.QueryProgress>
}
export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>(
{
QueryClient,
key,
query,
}: MakeProps<K, A, FallbackA, E, HandledE, R>
): Effect.Effect<
QueryRunner<K, A | FallbackA, Exclude<E, HandledE>>,
never,
R | QueryClient.TagClassShape<FallbackA, HandledE>
> => Effect.gen(function*() {
const context = yield* Effect.context<R | QueryClient.TagClassShape<FallbackA, HandledE>>()
const latestKeyValueRef = yield* SubscriptionRef.make(Option.none<K>())
const stateRef = yield* SubscriptionRef.make(AsyncData.noData<A | FallbackA, Exclude<E, HandledE>>())
const fiberRef = yield* SubscriptionRef.make(Option.none<Fiber.RuntimeFiber<
AsyncData.Success<A | FallbackA> | AsyncData.Failure<Exclude<E, HandledE>>,
Cause.NoSuchElementException
>>())
const queryStateTag = QueryState.makeTag<A | FallbackA, Exclude<E, HandledE>>()
const interrupt = Effect.flatMap(fiberRef, Option.match({
onSome: fiber => Ref.set(fiberRef, Option.none()).pipe(
Effect.andThen(Fiber.interrupt(fiber))
),
onNone: () => Effect.void,
}))
const forkInterrupt = Effect.flatMap(fiberRef, Option.match({
onSome: fiber => Ref.set(fiberRef, Option.none()).pipe(
Effect.andThen(Fiber.interrupt(fiber).pipe(
Effect.asVoid,
Effect.forkDaemon,
))
),
onNone: () => Effect.forkDaemon(Effect.void),
}))
const run = (keyValue: K) => Effect.all([QueryClient, queryStateTag]).pipe(
Effect.flatMap(([client, state]) => Ref.set(latestKeyValueRef, Option.some(keyValue)).pipe(
Effect.andThen(query(keyValue)),
client.errorHandler.handle,
Effect.matchCauseEffect({
onSuccess: v => Effect.tap(Effect.succeed(AsyncData.success(v)), state.set),
onFailure: c => Effect.tap(Effect.succeed(AsyncData.failure(c)), state.set),
}),
)),
Effect.provide(context),
Effect.provide(QueryProgress.QueryProgress.Default),
)
const forkFetch = (keyValue: K) => Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>().pipe(
Effect.flatMap(stateQueue => queryStateTag.pipe(
Effect.flatMap(state => interrupt.pipe(
Effect.andThen(
Effect.addFinalizer(() => Effect.andThen(
Ref.set(fiberRef, Option.none()),
Queue.shutdown(stateQueue),
)).pipe(
Effect.andThen(state.set(AsyncData.loading())),
Effect.andThen(run(keyValue)),
Effect.scoped,
Effect.forkDaemon,
)
),
Effect.tap(fiber => Ref.set(fiberRef, Option.some(fiber))),
Effect.map(fiber => [fiber, Stream.fromQueue(stateQueue)] as const),
)),
Effect.provide(QueryState.layer(
queryStateTag,
stateRef,
value => Effect.andThen(
Queue.offer(stateQueue, value),
Ref.set(stateRef, value),
),
)),
))
)
const setInitialRefreshState = Effect.flatMap(queryStateTag, state => state.update(previous => {
if (AsyncData.isSuccess(previous) || AsyncData.isFailure(previous))
return AsyncData.refreshing(previous)
if (AsyncData.isRefreshing(previous))
return AsyncData.refreshing(previous.previous)
return AsyncData.loading()
}))
const forkRefresh = Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>().pipe(
Effect.flatMap(stateQueue => interrupt.pipe(
Effect.andThen(
Effect.addFinalizer(() => Effect.andThen(
Ref.set(fiberRef, Option.none()),
Queue.shutdown(stateQueue),
)).pipe(
Effect.andThen(setInitialRefreshState),
Effect.andThen(latestKeyValueRef.pipe(
Effect.flatMap(identity),
Effect.flatMap(run),
)),
Effect.scoped,
Effect.forkDaemon,
)
),
Effect.tap(fiber => Ref.set(fiberRef, Option.some(fiber))),
Effect.map(fiber => [fiber, Stream.fromQueue(stateQueue)] as const),
Effect.provide(QueryState.layer(
queryStateTag,
stateRef,
value => Effect.andThen(
Queue.offer(stateQueue, value),
Ref.set(stateRef, value),
),
)),
))
)
return {
queryKey: key,
latestKeyValueRef,
stateRef,
fiberRef,
interrupt,
forkInterrupt,
forkFetch,
forkRefresh,
}
})
export interface RunOptions {
readonly refreshOnWindowFocus?: boolean
}
export const run = <K extends readonly unknown[], A, E>(
self: QueryRunner<K, A, E>,
options?: RunOptions,
): Effect.Effect<void, never, Scope.Scope> => Effect.gen(function*() {
if (typeof window !== "undefined" && (options?.refreshOnWindowFocus ?? true))
yield* Effect.forkScoped(
Stream.runForEach(BrowserStream.fromEventListenerWindow("focus"), () => self.forkRefresh)
)
yield* Effect.addFinalizer(() => self.interrupt)
yield* Stream.runForEach(Stream.changes(self.queryKey), latestKey => self.forkFetch(latestKey))
})

View File

@@ -0,0 +1,16 @@
import type * as AsyncData from "@typed/async-data"
import { type Cause, Effect, type Fiber, type Option, type Stream, type SubscriptionRef } from "effect"
export interface QueryService<K extends readonly unknown[], A, E> {
readonly latestKey: SubscriptionRef.SubscriptionRef<Option.Option<K>>
readonly state: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly forkRefresh: Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>, Cause.NoSuchElementException>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
}
export const Tag = <const Id extends string>(id: Id) => <
Self, K extends readonly unknown[], A, E = never,
>() => Effect.Tag(id)<Self, QueryService<K, A, E>>()

View File

@@ -1,6 +1,6 @@
export * as MutationRunner from "./MutationRunner.js"
export * as MutationService from "./MutationService.js"
export * as QueryClient from "./QueryClient.js"
export * as QueryErrorHandler from "./QueryErrorHandler.js"
export * from "./QueryExtension.js"
export * as QueryProgress from "./QueryProgress.js"
export * as QueryRunner from "./QueryRunner.js"
export * as QueryService from "./QueryService.js"

View File

@@ -1,11 +1,12 @@
import * as AsyncData from "@typed/async-data"
import { Effect, type Fiber, Queue, Ref, Stream, SubscriptionRef } from "effect"
import type * as QueryClient from "./QueryClient.js"
import * as QueryProgress from "./QueryProgress.js"
import { QueryState } from "./internal/index.js"
import { type Context, Effect, type Fiber, Queue, Ref, Stream, SubscriptionRef } from "effect"
import type * as QueryClient from "../QueryClient.js"
import * as QueryProgress from "../QueryProgress.js"
import * as QueryState from "./QueryState.js"
export interface MutationRunner<K extends readonly unknown[], A, E> {
export interface MutationRunner<K extends readonly unknown[], A, E, R> {
readonly context: Context.Context<R>
readonly stateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly mutate: (...key: K) => Effect.Effect<AsyncData.Success<A> | AsyncData.Failure<E>>
@@ -16,11 +17,6 @@ export interface MutationRunner<K extends readonly unknown[], A, E> {
}
export const Tag = <const Id extends string>(id: Id) => <
Self, K extends readonly unknown[], A, E = never,
>() => Effect.Tag(id)<Self, MutationRunner<K, A, E>>()
export interface MakeProps<K extends readonly unknown[], A, FallbackA, E, HandledE, R> {
readonly QueryClient: QueryClient.GenericTagClass<FallbackA, HandledE>
readonly mutation: (key: K) => Effect.Effect<A, E, R | QueryProgress.QueryProgress>
@@ -32,7 +28,7 @@ export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>
mutation,
}: MakeProps<K, A, FallbackA, E, HandledE, R>
): Effect.Effect<
MutationRunner<K, A | FallbackA, Exclude<E, HandledE>>,
MutationRunner<K, A | FallbackA, Exclude<E, HandledE>, R>,
never,
R | QueryClient.TagClassShape<FallbackA, HandledE>
> => Effect.gen(function*() {
@@ -41,18 +37,25 @@ export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>
const queryStateTag = QueryState.makeTag<A | FallbackA, Exclude<E, HandledE>>()
const run = (key: K) => Effect.all([QueryClient, queryStateTag]).pipe(
Effect.flatMap(([client, state]) => state.set(AsyncData.loading()).pipe(
const run = (key: K) => Effect.Do.pipe(
Effect.bind("state", () => queryStateTag),
Effect.bind("client", () => QueryClient),
Effect.flatMap(({ state, client }) => state.set(AsyncData.loading()).pipe(
Effect.andThen(mutation(key)),
client.errorHandler.handle,
Effect.matchCauseEffect({
onSuccess: v => Effect.tap(Effect.succeed(AsyncData.success(v)), state.set),
onFailure: c => Effect.tap(Effect.succeed(AsyncData.failure(c)), state.set),
onSuccess: v => Effect.succeed(AsyncData.success(v)).pipe(
Effect.tap(state.set)
),
onFailure: c => Effect.succeed(AsyncData.failure(c)).pipe(
Effect.tap(state.set)
),
}),
)),
Effect.provide(context),
Effect.provide(QueryProgress.QueryProgress.Default),
Effect.provide(QueryProgress.QueryProgress.Live),
)
const mutate = (...key: K) => Effect.provide(run(key), QueryState.layer(
@@ -61,11 +64,11 @@ export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>
value => Ref.set(globalStateRef, value),
))
const forkMutate = (...key: K) => Effect.all([
Ref.make(AsyncData.noData<A | FallbackA, Exclude<E, HandledE>>()),
Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>(),
]).pipe(
Effect.flatMap(([stateRef, stateQueue]) =>
const forkMutate = (...key: K) => Effect.Do.pipe(
Effect.bind("stateRef", () => Ref.make(AsyncData.noData<A | FallbackA, Exclude<E, HandledE>>())),
Effect.bind("stateQueue", () => Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>()),
Effect.flatMap(({ stateRef, stateQueue }) =>
Effect.addFinalizer(() => Queue.shutdown(stateQueue)).pipe(
Effect.andThen(run(key)),
Effect.scoped,

View File

@@ -0,0 +1,191 @@
import { BrowserStream } from "@effect/platform-browser"
import * as AsyncData from "@typed/async-data"
import { type Cause, type Context, Effect, Fiber, identity, Option, Queue, Ref, type Scope, Stream, SubscriptionRef } from "effect"
import type * as QueryClient from "../QueryClient.js"
import * as QueryProgress from "../QueryProgress.js"
import * as QueryState from "./QueryState.js"
export interface QueryRunner<K extends readonly unknown[], A, E, R> {
readonly context: Context.Context<R>
readonly latestKeyRef: SubscriptionRef.SubscriptionRef<Option.Option<K>>
readonly stateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<A, E>>
readonly fiberRef: SubscriptionRef.SubscriptionRef<Option.Option<Fiber.RuntimeFiber<
AsyncData.Success<A> | AsyncData.Failure<E>,
Cause.NoSuchElementException
>>>
readonly forkInterrupt: Effect.Effect<Fiber.RuntimeFiber<void, Cause.NoSuchElementException>>
readonly forkFetch: Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>, Cause.NoSuchElementException>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
readonly forkRefresh: Effect.Effect<readonly [
fiber: Fiber.RuntimeFiber<AsyncData.Success<A> | AsyncData.Failure<E>, Cause.NoSuchElementException>,
state: Stream.Stream<AsyncData.AsyncData<A, E>>,
]>
readonly fetchOnKeyChange: Effect.Effect<void, Cause.NoSuchElementException, Scope.Scope>
readonly refreshOnWindowFocus: Effect.Effect<void>
}
export interface MakeProps<K extends readonly unknown[], A, FallbackA, E, HandledE, R> {
readonly QueryClient: QueryClient.GenericTagClass<FallbackA, HandledE>
readonly key: Stream.Stream<K>
readonly query: (key: K) => Effect.Effect<A, E, R | QueryProgress.QueryProgress>
}
export const make = <K extends readonly unknown[], A, FallbackA, E, HandledE, R>(
{
QueryClient,
key,
query,
}: MakeProps<K, A, FallbackA, E, HandledE, R>
): Effect.Effect<
QueryRunner<K, A | FallbackA, Exclude<E, HandledE>, R>,
never,
R | QueryClient.TagClassShape<FallbackA, HandledE>
> => Effect.gen(function*() {
const context = yield* Effect.context<R | QueryClient.TagClassShape<FallbackA, HandledE>>()
const latestKeyRef = yield* SubscriptionRef.make(Option.none<K>())
const stateRef = yield* SubscriptionRef.make(AsyncData.noData<A | FallbackA, Exclude<E, HandledE>>())
const fiberRef = yield* SubscriptionRef.make(Option.none<Fiber.RuntimeFiber<
AsyncData.Success<A | FallbackA> | AsyncData.Failure<Exclude<E, HandledE>>,
Cause.NoSuchElementException
>>())
const queryStateTag = QueryState.makeTag<A | FallbackA, Exclude<E, HandledE>>()
const interrupt = fiberRef.pipe(
Effect.flatMap(Option.match({
onSome: fiber => Ref.set(fiberRef, Option.none()).pipe(
Effect.andThen(Fiber.interrupt(fiber))
),
onNone: () => Effect.void,
}))
)
const forkInterrupt = fiberRef.pipe(
Effect.flatMap(Option.match({
onSome: fiber => Ref.set(fiberRef, Option.none()).pipe(
Effect.andThen(Fiber.interrupt(fiber).pipe(
Effect.asVoid,
Effect.forkDaemon,
))
),
onNone: () => Effect.forkDaemon(Effect.void),
}))
)
const run = Effect.Do.pipe(
Effect.bind("state", () => queryStateTag),
Effect.bind("client", () => QueryClient),
Effect.bind("latestKey", () => latestKeyRef.pipe(Effect.flatMap(identity))),
Effect.flatMap(({ state, client, latestKey }) => query(latestKey).pipe(
client.errorHandler.handle,
Effect.matchCauseEffect({
onSuccess: v => Effect.succeed(AsyncData.success(v)).pipe(
Effect.tap(state.set)
),
onFailure: c => Effect.succeed(AsyncData.failure(c)).pipe(
Effect.tap(state.set)
),
}),
)),
Effect.provide(context),
Effect.provide(QueryProgress.QueryProgress.Live),
)
const forkFetch = Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>().pipe(
Effect.flatMap(stateQueue => queryStateTag.pipe(
Effect.flatMap(state => interrupt.pipe(
Effect.andThen(Effect.addFinalizer(() => Ref.set(fiberRef, Option.none()).pipe(
Effect.andThen(Queue.shutdown(stateQueue))
)).pipe(
Effect.andThen(state.set(AsyncData.loading())),
Effect.andThen(run),
Effect.scoped,
Effect.forkDaemon,
)),
Effect.tap(fiber => Ref.set(fiberRef, Option.some(fiber))),
Effect.map(fiber => [fiber, Stream.fromQueue(stateQueue)] as const),
)),
Effect.provide(QueryState.layer(
queryStateTag,
stateRef,
value => Queue.offer(stateQueue, value).pipe(
Effect.andThen(Ref.set(stateRef, value))
),
)),
))
)
const setInitialRefreshState = queryStateTag.pipe(
Effect.flatMap(state => state.update(previous => {
if (AsyncData.isSuccess(previous) || AsyncData.isFailure(previous))
return AsyncData.refreshing(previous)
if (AsyncData.isRefreshing(previous))
return AsyncData.refreshing(previous.previous)
return AsyncData.loading()
}))
)
const forkRefresh = Queue.unbounded<AsyncData.AsyncData<A | FallbackA, Exclude<E, HandledE>>>().pipe(
Effect.flatMap(stateQueue => interrupt.pipe(
Effect.andThen(Effect.addFinalizer(() => Ref.set(fiberRef, Option.none()).pipe(
Effect.andThen(Queue.shutdown(stateQueue))
)).pipe(
Effect.andThen(setInitialRefreshState),
Effect.andThen(run),
Effect.scoped,
Effect.forkDaemon,
)),
Effect.tap(fiber => Ref.set(fiberRef, Option.some(fiber))),
Effect.map(fiber => [fiber, Stream.fromQueue(stateQueue)] as const),
Effect.provide(QueryState.layer(
queryStateTag,
stateRef,
value => Queue.offer(stateQueue, value).pipe(
Effect.andThen(Ref.set(stateRef, value))
),
)),
))
)
const fetchOnKeyChange = Effect.addFinalizer(() => interrupt).pipe(
Effect.andThen(Stream.runForEach(Stream.changes(key), latestKey =>
Ref.set(latestKeyRef, Option.some(latestKey)).pipe(
Effect.andThen(forkFetch)
)
))
)
const refreshOnWindowFocus = Stream.runForEach(
BrowserStream.fromEventListenerWindow("focus"),
() => forkRefresh,
)
return {
context,
latestKeyRef,
stateRef,
fiberRef,
forkInterrupt,
forkFetch,
forkRefresh,
fetchOnKeyChange,
refreshOnWindowFocus,
}
})

View File

@@ -1 +1,3 @@
export * as MutationRunner from "./MutationRunner.js"
export * as QueryRunner from "./QueryRunner.js"
export * as QueryState from "./QueryState.js"

View File

@@ -1,6 +1,6 @@
{
"name": "reffuse",
"version": "0.1.13",
"version": "0.1.9",
"type": "module",
"files": [
"./README.md",
@@ -35,7 +35,7 @@
},
"peerDependencies": {
"@types/react": "^19.0.0",
"effect": "^3.15.0",
"effect": "^3.13.0",
"react": "^19.0.0"
}
}

View File

@@ -1,4 +1,4 @@
import { Array, Context, Effect, ExecutionStrategy, Exit, Layer, Match, Ref, Runtime, Scope } from "effect"
import { Array, Context, Effect, ExecutionStrategy, Exit, Layer, Ref, Runtime, Scope } from "effect"
import * as React from "react"
import * as ReffuseRuntime from "./ReffuseRuntime.js"
@@ -25,8 +25,6 @@ export type R<T> = T extends ReffuseContext<infer R> ? R : never
export type ReactProvider<R> = React.FC<{
readonly layer: Layer.Layer<R, unknown, Scope.Scope>
readonly scope?: Scope.Scope
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy
readonly finalizerExecutionMode?: "sync" | "fork"
readonly children?: React.ReactNode
}>
@@ -34,25 +32,16 @@ const makeProvider = <R>(Context: React.Context<Context.Context<R>>): ReactProvi
return function ReffuseContextReactProvider(props) {
const runtime = ReffuseRuntime.useRuntime()
const runSync = React.useMemo(() => Runtime.runSync(runtime), [runtime])
const runFork = React.useMemo(() => Runtime.runFork(runtime), [runtime])
const makeScope = React.useMemo(() => props.scope
? Scope.fork(props.scope, props.finalizerExecutionStrategy ?? ExecutionStrategy.sequential)
: Scope.make(props.finalizerExecutionStrategy ?? ExecutionStrategy.sequential),
? Scope.fork(props.scope, ExecutionStrategy.sequential)
: Scope.make(),
[props.scope])
const makeContext = (scope: Scope.CloseableScope) => Effect.context<R>().pipe(
const makeContext = React.useCallback((scope: Scope.CloseableScope) => Effect.context<R>().pipe(
Effect.provide(props.layer),
Effect.provideService(Scope.Scope, scope),
)
const closeScope = (scope: Scope.CloseableScope) => Scope.close(scope, Exit.void).pipe(
effect => Match.value(props.finalizerExecutionMode ?? "sync").pipe(
Match.when("sync", () => { runSync(effect) }),
Match.when("fork", () => { runFork(effect) }),
Match.exhaustive,
)
)
), [props.layer])
const [isInitialRun, initialScope, initialValue] = React.useMemo(() => Effect.Do.pipe(
Effect.bind("isInitialRun", () => Ref.make(true)),
@@ -68,7 +57,7 @@ const makeProvider = <R>(Context: React.Context<Context.Context<R>>): ReactProvi
Effect.if({
onTrue: () => Ref.set(isInitialRun, false).pipe(
Effect.map(() =>
() => closeScope(initialScope)
() => runSync(Scope.close(initialScope, Exit.void))
)
),
@@ -79,13 +68,13 @@ const makeProvider = <R>(Context: React.Context<Context.Context<R>>): ReactProvi
Effect.sync(() => setValue(context))
),
Effect.map(({ scope }) =>
() => closeScope(scope)
() => runSync(Scope.close(scope, Exit.void))
),
),
}),
runSync,
), [makeScope, runSync, runFork])
), [makeScope, makeContext, runSync])
return React.createElement(Context, { ...props, value })
}
@@ -95,7 +84,6 @@ export type AsyncReactProvider<R> = React.FC<{
readonly layer: Layer.Layer<R, unknown, Scope.Scope>
readonly scope?: Scope.Scope
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy
readonly finalizerExecutionMode?: "sync" | "fork"
readonly fallback?: React.ReactNode
readonly children?: React.ReactNode
}>
@@ -124,7 +112,7 @@ const makeAsyncProvider = <R>(Context: React.Context<Context.Context<R>>): Async
const scope = runSync(props.scope
? Scope.fork(props.scope, props.finalizerExecutionStrategy ?? ExecutionStrategy.sequential)
: Scope.make(props.finalizerExecutionStrategy ?? ExecutionStrategy.sequential)
: Scope.make(props.finalizerExecutionStrategy)
)
Effect.context<R>().pipe(
@@ -138,13 +126,7 @@ const makeAsyncProvider = <R>(Context: React.Context<Context.Context<R>>): Async
effect => runFork(effect, { ...props, scope }),
)
return () => Scope.close(scope, Exit.void).pipe(
effect => Match.value(props.finalizerExecutionMode ?? "sync").pipe(
Match.when("sync", () => { runSync(effect) }),
Match.when("fork", () => { runFork(effect) }),
Match.exhaustive,
)
)
return () => { runFork(Scope.close(scope, Exit.void)) }
}, [props.layer, runSync, runFork])
return React.createElement(React.Suspense, {

View File

@@ -1,4 +1,4 @@
import { type Context, Effect, ExecutionStrategy, Exit, type Fiber, Layer, Match, Option, pipe, Pipeable, PubSub, Ref, Runtime, Scope, Stream, SubscriptionRef } from "effect"
import { type Context, Effect, ExecutionStrategy, Exit, type Fiber, type Layer, Option, pipe, Pipeable, Queue, Ref, Runtime, Scope, Stream, SubscriptionRef } from "effect"
import * as React from "react"
import * as ReffuseContext from "./ReffuseContext.js"
import * as ReffuseRuntime from "./ReffuseRuntime.js"
@@ -14,11 +14,6 @@ export interface ScopeOptions {
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy
}
export interface UseScopeOptions extends RenderOptions, ScopeOptions {
readonly scope?: Scope.Scope
readonly finalizerExecutionMode?: "sync" | "fork"
}
export type RefsA<T extends readonly SubscriptionRef.SubscriptionRef<any>[]> = {
[K in keyof T]: Effect.Effect.Success<T[K]>
}
@@ -28,8 +23,7 @@ export abstract class ReffuseNamespace<R> {
declare ["constructor"]: ReffuseNamespaceClass<R>
constructor() {
this.SubRefFromGetSet = this.SubRefFromGetSet.bind(this as any) as any
this.SubRefFromPath = this.SubRefFromPath.bind(this as any) as any
this.SubRef = this.SubRef.bind(this as any) as any
this.SubscribeRefs = this.SubscribeRefs.bind(this as any) as any
this.RefState = this.RefState.bind(this as any) as any
this.SubscribeStream = this.SubscribeStream.bind(this as any) as any
@@ -94,56 +88,6 @@ export abstract class ReffuseNamespace<R> {
), [runtime, context])
}
useScope<R>(
this: ReffuseNamespace<R>,
deps: React.DependencyList = [],
options?: UseScopeOptions,
): readonly [scope: Scope.Scope, layer: Layer.Layer<Scope.Scope>] {
const runSync = this.useRunSync()
const runFork = this.useRunFork()
const makeScope = React.useMemo(() => options?.scope
? Scope.fork(options.scope, options.finalizerExecutionStrategy ?? ExecutionStrategy.sequential)
: Scope.make(options?.finalizerExecutionStrategy ?? ExecutionStrategy.sequential),
[options?.scope])
const closeScope = (scope: Scope.CloseableScope) => Scope.close(scope, Exit.void).pipe(
effect => Match.value(options?.finalizerExecutionMode ?? "sync").pipe(
Match.when("sync", () => { runSync(effect) }),
Match.when("fork", () => { runFork(effect) }),
Match.exhaustive,
)
)
const [isInitialRun, initialScope] = React.useMemo(() => runSync(
Effect.all([Ref.make(true), makeScope])
), [makeScope])
const [scope, setScope] = React.useState(initialScope)
React.useEffect(() => isInitialRun.pipe(
Effect.if({
onTrue: () => Effect.as(
Ref.set(isInitialRun, false),
() => closeScope(initialScope),
),
onFalse: () => makeScope.pipe(
Effect.tap(v => Effect.sync(() => setScope(v))),
Effect.map(v => () => closeScope(v)),
),
}),
runSync,
), [
makeScope,
...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runSync, runFork],
...deps,
])
return React.useMemo(() => [scope, Layer.succeed(Scope.Scope, scope)] as const, [scope])
}
/**
* Reffuse equivalent to `React.useMemo`.
*
@@ -167,6 +111,53 @@ export abstract class ReffuseNamespace<R> {
])
}
useMemoScoped<A, E, R>(
this: ReffuseNamespace<R>,
effect: () => Effect.Effect<A, E, R | Scope.Scope>,
deps: React.DependencyList,
options?: RenderOptions & ScopeOptions,
): A {
const runSync = this.useRunSync()
const [isInitialRun, initialScope, initialValue] = React.useMemo(() => Effect.Do.pipe(
Effect.bind("isInitialRun", () => Ref.make(true)),
Effect.bind("scope", () => Scope.make(options?.finalizerExecutionStrategy)),
Effect.bind("value", ({ scope }) => Effect.provideService(effect(), Scope.Scope, scope)),
Effect.map(({ isInitialRun, scope, value }) => [isInitialRun, scope, value] as const),
runSync,
), [])
const [value, setValue] = React.useState(initialValue)
React.useEffect(() => isInitialRun.pipe(
Effect.if({
onTrue: () => Ref.set(isInitialRun, false).pipe(
Effect.map(() =>
() => runSync(Scope.close(initialScope, Exit.void))
)
),
onFalse: () => Effect.Do.pipe(
Effect.bind("scope", () => Scope.make(options?.finalizerExecutionStrategy)),
Effect.bind("value", ({ scope }) => Effect.provideService(effect(), Scope.Scope, scope)),
Effect.tap(({ value }) =>
Effect.sync(() => setValue(value))
),
Effect.map(({ scope }) =>
() => runSync(Scope.close(scope, Exit.void))
),
),
}),
runSync,
), [
...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runSync],
...deps,
])
return value
}
/**
* Reffuse equivalent to `React.useEffect`.
*
@@ -387,39 +378,18 @@ export abstract class ReffuseNamespace<R> {
])
}
useRef<A, E, R>(
useRef<A, R>(
this: ReffuseNamespace<R>,
initialValue: () => Effect.Effect<A, E, R>,
value: A,
): SubscriptionRef.SubscriptionRef<A> {
return this.useMemo(
() => Effect.flatMap(initialValue(), SubscriptionRef.make),
() => SubscriptionRef.make(value),
[],
{ doNotReExecuteOnRuntimeOrContextChange: true }, // Do not recreate the ref when the context changes
)
}
useRefFromReactiveValue<A, R>(
this: ReffuseNamespace<R>,
value: A,
): SubscriptionRef.SubscriptionRef<A> {
const ref = this.useRef(() => Effect.succeed(value))
this.useEffect(() => Ref.set(ref, value), [value], { doNotReExecuteOnRuntimeOrContextChange: true })
return ref
}
useSubRefFromGetSet<A, B, R>(
this: ReffuseNamespace<R>,
parent: SubscriptionRef.SubscriptionRef<B>,
getter: (parentValue: B) => A,
setter: (parentValue: B, value: A) => B,
): SubscriptionSubRef.SubscriptionSubRef<A, B> {
return React.useMemo(
() => SubscriptionSubRef.makeFromGetSet(parent, getter, setter),
[parent],
)
}
useSubRefFromPath<B, const P extends PropertyPath.Paths<B>, R>(
useSubRef<B, const P extends PropertyPath.Paths<B>, R>(
this: ReffuseNamespace<R>,
parent: SubscriptionRef.SubscriptionRef<B>,
path: P,
@@ -485,77 +455,36 @@ export abstract class ReffuseNamespace<R> {
return [reactStateValue, setValue]
}
useStreamFromReactiveValues<const A extends React.DependencyList, R>(
useStreamFromValues<const A extends React.DependencyList, R>(
this: ReffuseNamespace<R>,
values: A,
): Stream.Stream<A> {
const [, scopeLayer] = this.useScope([], { finalizerExecutionMode: "fork" })
const [queue, stream] = this.useMemo(() => Queue.unbounded<A>().pipe(
Effect.map(queue => [queue, Stream.fromQueue(queue)] as const)
), [])
const { latest, pubsub, stream } = this.useMemo(() => Effect.Do.pipe(
Effect.bind("latest", () => Ref.make(values)),
Effect.bind("pubsub", () => Effect.acquireRelease(PubSub.unbounded<A>(), PubSub.shutdown)),
Effect.let("stream", ({ latest, pubsub }) => Ref.get(latest).pipe(
Effect.flatMap(a => Effect.map(
Stream.fromPubSub(pubsub, { scoped: true }),
s => Stream.concat(Stream.make(a), s),
)),
Stream.unwrapScoped,
)),
Effect.provide(scopeLayer),
), [scopeLayer], { doNotReExecuteOnRuntimeOrContextChange: true })
this.useEffect(() => Ref.set(latest, values).pipe(
Effect.andThen(PubSub.publish(pubsub, values)),
Effect.unlessEffect(PubSub.isShutdown(pubsub)),
), values, { doNotReExecuteOnRuntimeOrContextChange: true })
this.useEffect(() => Queue.offer(queue, values), values)
return stream
}
useSubscribeStream<A, E, R>(
useSubscribeStream<A, InitialA extends A | undefined, E, R>(
this: ReffuseNamespace<R>,
stream: Stream.Stream<A, E, R>,
): Option.Option<A>
useSubscribeStream<A, E, IE, R>(
this: ReffuseNamespace<R>,
stream: Stream.Stream<A, E, R>,
initialValue: () => Effect.Effect<A, IE, R>,
): Option.Some<A>
useSubscribeStream<A, E, IE, R>(
this: ReffuseNamespace<R>,
stream: Stream.Stream<A, E, R>,
initialValue?: () => Effect.Effect<A, IE, R>,
): Option.Option<A> {
const [reactStateValue, setReactStateValue] = React.useState(this.useMemo(
() => initialValue
? Effect.map(initialValue(), Option.some)
: Effect.succeed(Option.none()),
[],
{ doNotReExecuteOnRuntimeOrContextChange: true },
))
initialValue?: InitialA,
): InitialA extends A ? Option.Some<A> : Option.Option<A> {
const [reactStateValue, setReactStateValue] = React.useState<Option.Option<A>>(Option.fromNullable(initialValue))
this.useFork(() => Stream.runForEach(
Stream.changesWith(stream, (x, y) => x === y),
v => Effect.sync(() => setReactStateValue(Option.some(v))),
), [stream])
return reactStateValue
return reactStateValue as InitialA extends A ? Option.Some<A> : Option.Option<A>
}
SubRefFromGetSet<A, B, R>(
this: ReffuseNamespace<R>,
props: {
readonly parent: SubscriptionRef.SubscriptionRef<B>,
readonly getter: (parentValue: B) => A,
readonly setter: (parentValue: B, value: A) => B,
readonly children: (subRef: SubscriptionSubRef.SubscriptionSubRef<A, B>) => React.ReactNode
},
): React.ReactNode {
return props.children(this.useSubRefFromGetSet(props.parent, props.getter, props.setter))
}
SubRefFromPath<B, const P extends PropertyPath.Paths<B>, R>(
SubRef<B, const P extends PropertyPath.Paths<B>, R>(
this: ReffuseNamespace<R>,
props: {
readonly parent: SubscriptionRef.SubscriptionRef<B>,
@@ -563,7 +492,7 @@ export abstract class ReffuseNamespace<R> {
readonly children: (subRef: SubscriptionSubRef.SubscriptionSubRef<PropertyPath.ValueFromPath<B, P>, B>) => React.ReactNode
},
): React.ReactNode {
return props.children(this.useSubRefFromPath(props.parent, props.path))
return props.children(this.useSubRef(props.parent, props.path))
}
SubscribeRefs<
@@ -589,30 +518,15 @@ export abstract class ReffuseNamespace<R> {
return props.children(this.useRefState(props.ref))
}
SubscribeStream<A, E, R>(
SubscribeStream<A, InitialA extends A | undefined, E, R>(
this: ReffuseNamespace<R>,
props: {
readonly stream: Stream.Stream<A, E, R>
readonly children: (latestValue: Option.Option<A>) => React.ReactNode
},
): React.ReactNode
SubscribeStream<A, E, IE, R>(
this: ReffuseNamespace<R>,
props: {
readonly stream: Stream.Stream<A, E, R>
readonly initialValue: () => Effect.Effect<A, IE, R>
readonly children: (latestValue: Option.Some<A>) => React.ReactNode
},
): React.ReactNode
SubscribeStream<A, E, IE, R>(
this: ReffuseNamespace<R>,
props: {
readonly stream: Stream.Stream<A, E, R>
readonly initialValue?: () => Effect.Effect<A, IE, R>
readonly children: (latestValue: Option.Some<A>) => React.ReactNode
readonly initialValue?: InitialA
readonly children: (latestValue: InitialA extends A ? Option.Some<A> : Option.Option<A>) => React.ReactNode
},
): React.ReactNode {
return props.children(this.useSubscribeStream(props.stream, props.initialValue as () => Effect.Effect<A, IE, R>))
return props.children(this.useSubscribeStream(props.stream, props.initialValue))
}
}

View File

@@ -1,29 +1,24 @@
import { Array, Function, Option, Predicate } from "effect"
type Prev = readonly [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
export type Paths<T, D extends number = 5, Seen = never> = [] | (
D extends never ? [] :
T extends Seen ? [] :
T extends readonly any[] ? ArrayPaths<T, D, Seen | T> :
T extends object ? ObjectPaths<T, D, Seen | T> :
export type Paths<T> = [] | (
T extends readonly any[] ? ArrayPaths<T> :
T extends object ? ObjectPaths<T> :
never
)
export type ArrayPaths<T extends readonly any[], D extends number, Seen> = {
export type ArrayPaths<T extends readonly any[]> = {
[K in keyof T as K extends number ? K : never]:
| [K]
| [K, ...Paths<T[K], Prev[D], Seen>]
| [K, ...Paths<T[K]>]
} extends infer O
? O[keyof O]
: never
export type ObjectPaths<T extends object, D extends number, Seen> = {
[K in keyof T as K extends string | number | symbol ? K : never]-?:
NonNullable<T[K]> extends infer V
? [K] | [K, ...Paths<V, Prev[D], Seen>]
: never
export type ObjectPaths<T extends object> = {
[K in keyof T as K extends string | number | symbol ? K : never]:
| [K]
| [K, ...Paths<T[K]>]
} extends infer O
? O[keyof O]
: never

View File

@@ -52,7 +52,7 @@ class SubscriptionSubRefImpl<in out A, in out B> extends Effectable.Class<A> imp
readonly setter: (parentValue: B, value: A) => B,
) {
super()
this.get = Effect.map(Ref.get(this.parent), this.getter)
this.get = Ref.get(this.parent).pipe(Effect.map(this.getter))
}
commit() {