Skip to main content

路 9 min read
Nathaniel Tucker

@rest-hooks/experimental is a new package that allows us to quickly iterate on new designs by using them in production, which provides feedback in ways not possible at design and testing phase.

This package is not api stable; it does follow semver, so it will never reach 1.0. However, it is tested with the same rigor we expect with Rest Hooks as we use it in production. It is recommend to use this for providing feedback or playing with designs, unless you are willing to put in extra work to make migrations. Detailed migration guides will only be provided upon upstreaming to the mainline packages.

Today this package comes with two new features:

useController()

const { fetch, invalidate, resetEntireStore } = useController();fetch(MyResource.detail(), { id });

Resource.list().paginated()

class NewsResource extends Resource {  static listPage<T extends typeof NewsResource>(this: T) {    return this.list().paginated(({ cursor, ...rest }) => [rest]);  }}

路 One min read
Nathaniel Tucker

A lot of exciting features have been developed recently, resulting in many feature releases. We've been hard a work integrating them into Coinbase's various products, so I skipped a few release announcements. The biggest focus has been performance features - highlighted by adding true optimistic updates.

路 One min read
Nathaniel Tucker

4.1 comes with a more granular data definition hierarchy that will make it easier to write more API definitions. This marked by the introduction of a new member known as Entity. Entity only needs a pk() and get key(), as well as member declarations to integrate fully.

Entity#

  • Useful for nested entities that don't have endpoints like LatestPrice.
  • Useful for non-REST style APIs like GraphQL.
  • Simplifies defining nested entities.

路 4 min read
Nathaniel Tucker

2.2 comes with the eagerly awaited programmable optimistic updates. This enables two very important use cases: optimistic update on create and infinite pagination.

The bigger part of this release is introducing two new hooks that enable an incremental migration path to 3.0 planned changes. useCacheNew() and useResourceNew() are added in this release, allowing incremental adoption of the new selection logic that will become the default in 3.0. More details below.

路 3 min read
Nathaniel Tucker

New Features#

Reduced bundle size with custom networking library#

Resource comes with a default fetch() implementation to make getting started easy. It uses superagent as the networking library due to its server-side support as well as nice interface via the builder pattern. However, this comes at the cost of 6kb gziped added to the bundle. For those who want to use another networking library this is quite a cost to pay for a library that itself is well under 10kb gzip.

To solve this problem there is a new exported called SimpleResource. This provides all the Resource behavior without the fetch() implementation. If you're customizing fetch() or want to customize fetch(), simply follow the instructions to use SimpleResource as your base class now. With tree-shaking this will leave superagent out of your bundle and save a cool 6kb gzip.

Enable customizing networking library reducing bundle size #113

路 6 min read
Nathaniel Tucker

We use SemVer for Rest Hooks - so 2.0 represents some breaking changes. To minimize disruption we have been carefully considering these changes and awaiting community feedback to be confident these are the right changes to make.

While some of these changes are simple renames to make the library more intuitive - some represent important progress to empowering the next chapter of Rest Hooks.

See https://github.com/coinbase/rest-hooks/releases/tag/2.0.0 for a complete list of changes