Skip to content

Commit

Permalink
add Reactivity module
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Nov 11, 2024
1 parent a538303 commit 44d1c91
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 49 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-years-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-rx/rx": patch
---

add Reactivity module
6 changes: 3 additions & 3 deletions docs/rx-vue/index.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Added in v1.0.0
**Signature**

```ts
export declare const useRx: <R, W>(rx: Rx.Writable<R, W>) => readonly [Readonly<Ref<R, R>>, (_: W) => void]
export declare const useRx: <R, W>(rx: Rx.Writable<R, W>) => readonly [Readonly<Ref<R>>, (_: W) => void]
```
Added in v1.0.0
Expand All @@ -46,7 +46,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const useRxRef: <A>(rxRef: RxRef.ReadonlyRef<A>) => Readonly<Ref<A, A>>
export declare const useRxRef: <A>(rxRef: RxRef.ReadonlyRef<A>) => Readonly<Ref<A>>
```
Added in v1.0.0
Expand All @@ -66,7 +66,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const useRxValue: <A>(rx: Rx.Rx<A>) => Readonly<Ref<A, A>>
export declare const useRxValue: <A>(rx: Rx.Rx<A>) => Readonly<Ref<A>>
```
Added in v1.0.0
Expand Down
78 changes: 78 additions & 0 deletions docs/rx/Reactivity.ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: Reactivity.ts
nav_order: 2
parent: "@effect-rx/rx"
---

## Reactivity overview

Added in v1.0.0

---

<h2 class="text-delta">Table of contents</h2>

- [constructors](#constructors)
- [make](#make)
- [model](#model)
- [Reactivity (namespace)](#reactivity-namespace)
- [Service (interface)](#service-interface)
- [tags](#tags)
- [Reactivity (class)](#reactivity-class)

---

# constructors

## make

**Signature**

```ts
export declare const make: Effect.Effect<Reactivity.Service, never, never>
```
Added in v1.0.0
# model
## Reactivity (namespace)
Added in v1.0.0
### Service (interface)
**Signature**
```ts
export interface Service {
readonly unsafeInvalidate: (keys: ReadonlyArray<unknown> | ReadonlyRecord<string, Array<unknown>>) => void
readonly invalidate: (keys: ReadonlyArray<unknown> | ReadonlyRecord<string, Array<unknown>>) => Effect.Effect<void>
readonly mutation: <A, E, R>(
keys: ReadonlyArray<unknown> | ReadonlyRecord<string, Array<unknown>>,
effect: Effect.Effect<A, E, R>
) => Effect.Effect<A, E, R>
readonly query: <A, E, R>(
keys: ReadonlyArray<unknown> | ReadonlyRecord<string, Array<unknown>>,
effect: Effect.Effect<A, E, R>
) => Effect.Effect<Mailbox.ReadonlyMailbox<A, E>, never, R | Scope.Scope>
readonly stream: <A, E, R>(
keys: ReadonlyArray<unknown> | ReadonlyRecord<string, Array<unknown>>,
effect: Effect.Effect<A, E, R>
) => Stream.Stream<A, E, Exclude<R, Scope.Scope>>
}
```

Added in v1.0.0

# tags

## Reactivity (class)

**Signature**

```ts
export declare class Reactivity
```

Added in v1.0.0
2 changes: 1 addition & 1 deletion docs/rx/Registry.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Registry.ts
nav_order: 2
nav_order: 3
parent: "@effect-rx/rx"
---

Expand Down
23 changes: 15 additions & 8 deletions docs/rx/Result.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Result.ts
nav_order: 3
nav_order: 4
parent: "@effect-rx/rx"
---

Expand All @@ -15,6 +15,7 @@ Added in v1.0.0
- [accessors](#accessors)
- [cause](#cause)
- [getOrElse](#getorelse)
- [getOrThrow](#getorthrow)
- [value](#value)
- [combinators](#combinators)
- [map](#map)
Expand Down Expand Up @@ -74,13 +75,23 @@ Added in v1.0.0
```ts
export declare const getOrElse: {
<B>(orElse: LazyArg<B>): <A, E>(self: Result<A, E>) => B | A
<B>(orElse: LazyArg<B>): <A, E>(self: Result<A, E>) => A | B
<A, E, B>(self: Result<A, E>, orElse: LazyArg<B>): A | B
}
```
Added in v1.0.0
## getOrThrow
**Signature**
```ts
export declare const getOrThrow: <A, E>(self: Result<A, E>) => A
```
Added in v1.0.0
## value
**Signature**
Expand Down Expand Up @@ -187,7 +198,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const toExit: <A, E>(self: Result<A, E>) => Exit.Exit<A, Cause.NoSuchElementException | E>
export declare const toExit: <A, E>(self: Result<A, E>) => Exit.Exit<A, E | Cause.NoSuchElementException>
```
Added in v1.0.0
Expand All @@ -199,11 +210,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const fail: <A, E>(
error: E,
previousData?: Option.Option<A> | undefined,
waiting?: boolean
) => Failure<A, E>
export declare const fail: <A, E>(error: E, previousData?: Option.Option<A>, waiting?: boolean) => Failure<A, E>
```
Added in v1.0.0
Expand Down
57 changes: 21 additions & 36 deletions docs/rx/Rx.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Rx.ts
nav_order: 4
nav_order: 5
parent: "@effect-rx/rx"
---

Expand Down Expand Up @@ -226,14 +226,14 @@ export declare const withFallback: {
): <R extends Rx<Result.Result<any, any>>>(
self: R
) => [R] extends [Writable<infer _, infer RW>]
? Writable<Result.Result<A2 | Result.Result.InferA<Rx.Infer<R>>, E2 | Result.Result.InferE<Rx.Infer<R>>>, RW>
: Rx<Result.Result<A2 | Result.Result.InferA<Rx.Infer<R>>, E2 | Result.Result.InferE<Rx.Infer<R>>>>
? Writable<Result.Result<Result.Result.InferA<Rx.Infer<R>> | A2, Result.Result.InferE<Rx.Infer<R>> | E2>, RW>
: Rx<Result.Result<Result.Result.InferA<Rx.Infer<R>> | A2, Result.Result.InferE<Rx.Infer<R>> | E2>>
<R extends Rx<Result.Result<any, any>>, A2, E2>(
self: R,
fallback: Rx<Result.Result<A2, E2>>
): [R] extends [Writable<infer _, infer RW>]
? Writable<Result.Result<A2 | Result.Result.InferA<Rx.Infer<R>>, E2 | Result.Result.InferE<Rx.Infer<R>>>, RW>
: Rx<Result.Result<A2 | Result.Result.InferA<Rx.Infer<R>>, E2 | Result.Result.InferE<Rx.Infer<R>>>>
? Writable<Result.Result<Result.Result.InferA<Rx.Infer<R>> | A2, Result.Result.InferE<Rx.Infer<R>> | E2>, RW>
: Rx<Result.Result<Result.Result.InferA<Rx.Infer<R>> | A2, Result.Result.InferE<Rx.Infer<R>> | E2>>
}
```
Expand All @@ -259,9 +259,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const context: () => <R, E>(
create: Layer.Layer<R, E, never> | Rx.Read<Layer.Layer<R, E, never>>
) => RxRuntime<R, E>
export declare const context: () => <R, E>(create: Layer.Layer<R, E> | Rx.Read<Layer.Layer<R, E>>) => RxRuntime<R, E>
```
Added in v1.0.0
Expand All @@ -284,12 +282,12 @@ Added in v1.0.0
export declare const fn: {
<Arg, E, A>(
fn: Rx.ReadFn<Arg, Effect.Effect<A, E, Scope.Scope>>,
options?: { readonly initialValue?: A | undefined } | undefined
options?: { readonly initialValue?: A }
): RxResultFn<RxResultFn.ArgToVoid<Arg>, A, E>
<Arg, E, A>(
fn: Rx.ReadFn<Arg, Stream.Stream<A, E, never>>,
options?: { readonly initialValue?: A | undefined } | undefined
): RxResultFn<RxResultFn.ArgToVoid<Arg>, A, NoSuchElementException | E>
fn: Rx.ReadFn<Arg, Stream.Stream<A, E>>,
options?: { readonly initialValue?: A }
): RxResultFn<RxResultFn.ArgToVoid<Arg>, A, E | NoSuchElementException>
}
```
Expand All @@ -314,22 +312,13 @@ Added in v1.0.0
```ts
export declare const make: {
<A, E>(
effect: Effect.Effect<A, E, Scope.Scope>,
options?: { readonly initialValue?: A | undefined } | undefined
): Rx<Result.Result<A, E>>
<A, E>(effect: Effect.Effect<A, E, Scope.Scope>, options?: { readonly initialValue?: A }): Rx<Result.Result<A, E>>
<A, E>(
create: Rx.Read<Effect.Effect<A, E, Scope.Scope>>,
options?: { readonly initialValue?: A | undefined } | undefined
): Rx<Result.Result<A, E>>
<A, E>(
stream: Stream.Stream<A, E, never>,
options?: { readonly initialValue?: A | undefined } | undefined
): Rx<Result.Result<A, E>>
<A, E>(
create: Rx.Read<Stream.Stream<A, E, never>>,
options?: { readonly initialValue?: A | undefined } | undefined
options?: { readonly initialValue?: A }
): Rx<Result.Result<A, E>>
<A, E>(stream: Stream.Stream<A, E>, options?: { readonly initialValue?: A }): Rx<Result.Result<A, E>>
<A, E>(create: Rx.Read<Stream.Stream<A, E>>, options?: { readonly initialValue?: A }): Rx<Result.Result<A, E>>
<A>(create: Rx.Read<A>): Rx<A>
<A>(initialValue: A): Writable<A, A>
}
Expand All @@ -343,10 +332,8 @@ Added in v1.0.0
```ts
export declare const pull: <A, E>(
create: Stream.Stream<A, E, never> | Rx.Read<Stream.Stream<A, E, never>>,
options?:
| { readonly disableAccumulation?: boolean | undefined; readonly initialValue?: readonly A[] | undefined }
| undefined
create: Rx.Read<Stream.Stream<A, E>> | Stream.Stream<A, E>,
options?: { readonly disableAccumulation?: boolean; readonly initialValue?: ReadonlyArray<A> }
) => Writable<PullResult<A, E>, void>
```
Expand All @@ -368,12 +355,12 @@ Added in v1.0.0
```ts
export declare const subscribable: {
<A, E>(ref: Subscribable.Subscribable<A, E, never> | Rx.Read<Subscribable.Subscribable<A, E, never>>): Rx<A>
<A, E>(ref: Subscribable.Subscribable<A, E> | Rx.Read<Subscribable.Subscribable<A, E>>): Rx<A>
<A, E, E1>(
effect:
| Effect.Effect<Subscribable.Subscribable<A, E1, never>, E, never>
| Rx.Read<Effect.Effect<Subscribable.Subscribable<A, E1, never>, E, never>>
): Rx<A>
| Effect.Effect<Subscribable.Subscribable<A, E1>, E, never>
| Rx.Read<Effect.Effect<Subscribable.Subscribable<A, E1>, E, never>>
): Rx<Result.Result<A, E | E1>>
}
```
Expand Down Expand Up @@ -476,9 +463,7 @@ Added in v1.0.0
**Signature**

```ts
export declare const runtime: <R, E>(
create: Layer.Layer<R, E, never> | Rx.Read<Layer.Layer<R, E, never>>
) => RxRuntime<R, E>
export declare const runtime: <R, E>(create: Layer.Layer<R, E> | Rx.Read<Layer.Layer<R, E>>) => RxRuntime<R, E>
```
Added in v1.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/rx/RxRef.ts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: RxRef.ts
nav_order: 5
nav_order: 6
parent: "@effect-rx/rx"
---

Expand Down
5 changes: 5 additions & 0 deletions packages/rx-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { globalValue } from "effect/GlobalValue"
import * as React from "react"
import * as Scheduler from "scheduler"

/**
* @since 1.0.0
* @category modules
*/
export * as Reactivity from "@effect-rx/rx/Reactivity"
/**
* @since 1.0.0
* @category modules
Expand Down
5 changes: 5 additions & 0 deletions packages/rx-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { globalValue } from "effect/GlobalValue"
import type { InjectionKey, Ref } from "vue"
import { getCurrentScope, inject, onScopeDispose, ref } from "vue"

/**
* @since 1.0.0
* @category modules
*/
export * as Reactivity from "@effect-rx/rx/Reactivity"
/**
* @since 1.0.0
* @category modules
Expand Down
Loading

0 comments on commit 44d1c91

Please sign in to comment.