Skip to content

Commit

Permalink
Updating from 836611c
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 8, 2023
1 parent c68bee8 commit 0c7bfdc
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tansu.aswritable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@amadeus-it-group/tansu](./tansu.md) &gt; [asWritable](./tansu.aswritable.md)

## asWritable() function

Returns a wrapper (for the given store) which only exposes the [WritableSignal](./tansu.writablesignal.md) interface. When the value is changed from the given wrapper, the provided set function is called.

**Signature:**

```typescript
export declare function asWritable<T, W = T>(store: StoreInput<T>, set?: WritableSignal<T, W>['set']): WritableSignal<T, W>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| store | [StoreInput](./tansu.storeinput.md)<!-- -->&lt;T&gt; | store to wrap |
| set | [WritableSignal](./tansu.writablesignal.md)<!-- -->&lt;T, W&gt;\['set'\] | _(Optional)_ function that will be called when the value is changed from the wrapper (through the [set](./tansu.writable.set.md) or the [update](./tansu.writable.update.md) function). If set is not specified, a noop function is used (so the value of the store cannot be changed from the returned wrapper). |

**Returns:**

[WritableSignal](./tansu.writablesignal.md)<!-- -->&lt;T, W&gt;

A wrapper which only exposes the [WritableSignal](./tansu.writablesignal.md) interface.

27 changes: 27 additions & 0 deletions tansu.aswritable_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@amadeus-it-group/tansu](./tansu.md) &gt; [asWritable](./tansu.aswritable_1.md)

## asWritable() function

Returns a wrapper (for the given store) which only exposes the [WritableSignal](./tansu.writablesignal.md) interface and also adds the given extra properties on the returned object.

**Signature:**

```typescript
export declare function asWritable<T, U, W = T>(store: StoreInput<T>, extraProps: U & Partial<Pick<WritableSignal<T, W>, 'set' | 'update'>>): WritableSignal<T, W> & Omit<U, keyof WritableSignal<T, W>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| store | [StoreInput](./tansu.storeinput.md)<!-- -->&lt;T&gt; | store to wrap |
| extraProps | U &amp; Partial&lt;Pick&lt;[WritableSignal](./tansu.writablesignal.md)<!-- -->&lt;T, W&gt;, 'set' \| 'update'&gt;&gt; | object containing the extra properties to add on the returned object, and optionally the [set](./tansu.writable.set.md) and the [update](./tansu.writable.update.md) function of the [WritableSignal](./tansu.writablesignal.md) interface. If the set function is not specified, a noop function is used. If the update function is not specified, a default function that calls set is used. |

**Returns:**

[WritableSignal](./tansu.writablesignal.md)<!-- -->&lt;T, W&gt; &amp; Omit&lt;U, keyof [WritableSignal](./tansu.writablesignal.md)<!-- -->&lt;T, W&gt;&gt;

A wrapper which only exposes the [WritableSignal](./tansu.writablesignal.md) interface and the given extra properties.

13 changes: 13 additions & 0 deletions tansu.equal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@amadeus-it-group/tansu](./tansu.md) &gt; [equal](./tansu.equal.md)

## equal variable

Default implementation of the equal function used by tansu when a store changes, to know if listeners need to be notified. Returns false if `a` is a function or an object, or if `a` and `b` are different according to `Object.is`<!-- -->. Otherwise, returns true.

**Signature:**

```typescript
equal: <T>(a: T, b: T) => boolean
```
3 changes: 3 additions & 0 deletions tansu.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ tansu is a lightweight, push-based state management library. It borrows the idea
| --- | --- |
| [asReadable(store)](./tansu.asreadable.md) | Returns a wrapper (for the given store) which only exposes the [ReadableSignal](./tansu.readablesignal.md) interface. This converts any [StoreInput](./tansu.storeinput.md) to a [ReadableSignal](./tansu.readablesignal.md) and exposes the store as read-only. |
| [asReadable(store, extraProp)](./tansu.asreadable_1.md) | Returns a wrapper (for the given store) which only exposes the [ReadableSignal](./tansu.readablesignal.md) interface and also adds the given extra properties on the returned object. |
| [asWritable(store, set)](./tansu.aswritable.md) | Returns a wrapper (for the given store) which only exposes the [WritableSignal](./tansu.writablesignal.md) interface. When the value is changed from the given wrapper, the provided set function is called. |
| [asWritable(store, extraProps)](./tansu.aswritable_1.md) | Returns a wrapper (for the given store) which only exposes the [WritableSignal](./tansu.writablesignal.md) interface and also adds the given extra properties on the returned object. |
| [computed(fn, options)](./tansu.computed.md) | Creates a store whose value is computed by the provided function. |
| [derived(stores, options, initialValue)](./tansu.derived.md) | A convenience function to create a new store with a state computed from the latest values of dependent stores. Each time the state of one of the dependent stores changes, a provided derive function is called to compute a new, derived state. |
| [derived(stores, options, initialValue)](./tansu.derived_1.md) | |
Expand All @@ -45,6 +47,7 @@ tansu is a lightweight, push-based state management library. It borrows the idea
| Variable | Description |
| --- | --- |
| [batch](./tansu.batch.md) | Batches multiple changes to stores while calling the provided function, preventing derived stores from updating until the function returns, to avoid unnecessary recomputations. |
| [equal](./tansu.equal.md) | Default implementation of the equal function used by tansu when a store changes, to know if listeners need to be notified. Returns false if <code>a</code> is a function or an object, or if <code>a</code> and <code>b</code> are different according to <code>Object.is</code>. Otherwise, returns true. |
| [get](./tansu.get.md) | A utility function to get the current value from a given store. It works by subscribing to a store, capturing the value (synchronously) and unsubscribing just after. |
| [symbolObservable](./tansu.symbolobservable.md) | Symbol used in [InteropObservable](./tansu.interopobservable.md) allowing any object to expose an observable. |
| [untrack](./tansu.untrack.md) | Stops the tracking of dependencies made by [computed()](./tansu.computed.md) and calls the provided function. After the function returns, the tracking of dependencies continues as before. |
Expand Down

0 comments on commit 0c7bfdc

Please sign in to comment.