Skip to content

Commit

Permalink
update bench, make signals notify on change only by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Apr 10, 2021
1 parent a0d289e commit d86c1bc
Show file tree
Hide file tree
Showing 23 changed files with 1,059 additions and 484 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 0.26.0 - 2021-04-09

This release is about finalizing some API changes on the road to 1.0. This one has one breaking change and not much else.

#### Signals no longer always notify by default

Solid's original behavior has been to always notify on signal change even if the value hasn't changed. The idea was to simulate stream behavior. However, this has some downsides:

1. Inconsistent with State.. I made the decision to make state equality check by default, it is weird signals and memo's do not.
2. More likely to hit infinite loops. Equality check naturally stops infinite loops in some cases. While infinite loops aren't good and code that produces them suspect, it is nice to keep things clean.
3. It is consistent with other modern reactive libraries like MobX and Vue.

The API has not changed. You can opt out of the default behavior by passing in your own comparator or false to the 2nd parameter of `createSignal` and the 3rd parameter of `createMemo`.

My hope this is the last release before I start making 1.0 RC's. This one has big enough impact I want to get this out first. I imagine the remaining changes will be just syntax.

## 0.25.0 - 2021-03-28

This release is about refining the the APIs as we approach the our release candidate for 1.0.
Expand Down
4 changes: 2 additions & 2 deletions documentation/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ Creates a new computation that automatically tracks dependencies and runs during
Creates a conditional signal that only notifies subscribers when entering or exiting their key matching the value. Useful for delegated selection state.

### `createResource(fetcher, { initialValue }): [getValueFn, { mutate, refetch }]`
### `createResource(fn, fetcher, { initialValue }): [getValueFn, { mutate, refetch }]`
### `createResource(source, fetcher, { initialValue }): [getValueFn, { mutate, refetch }]`

Creates a new resource signal that can hold an async resource. Resources when read while loading trigger Suspense. The `fetcher` is a function that accepts return value of the `trackingFn` if provided and returns a Promise whose resolved value is set in the resource. The fetcher is not reactive so use the optional first argument if you want it to run more than once. If provided false, null, or undefined signals not to fetch.
Creates a new resource signal that can hold an async resource. Resources when read while loading trigger Suspense. The `fetcher` is a function that accepts return value of the `source` if provided and returns a Promise whose resolved value is set in the resource. The fetcher is not reactive so use the optional first argument if you want it to run more than once. If provided false, null, or undefined signals not to fetch.

### `lazy(() => <Promise>): Component`

Expand Down
2 changes: 1 addition & 1 deletion documentation/suspense.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ let [user, { refetch, mutate }] = createResource(
fetchJSON);
```

The first argument can be a unique string key or dynamically generated one that is automatically tracked in a function.
The first argument is the value to be passed into the fetcher. If it is a function it will be tracked. If it is null or undefined the fetcher will not be executed. It can be omitted commpletely as well if the resource only fires once and you wish to put all your logic in the fetcher.

> **For React Users:** At the time of writing this React has not completely settled how their Data Fetching API will look. Solid ships with this feature today, and it might differ from what React ultimately lands on.
Expand Down
Loading

0 comments on commit d86c1bc

Please sign in to comment.