Skip to content

Releases: octet-stream/use-suspender

2.0.0-beta.0

09 Apr 21:24
Compare
Choose a tag to compare
2.0.0-beta.0 Pre-release
Pre-release

Update

  • Rewrite project with TypeScript;
  • Rewrite documentation;
  • Expand cache so it can hold multiple operations. With that, when useSuspender is called with different arguments - each call will create a new operation. However, if called with the same arguments, the same operation will be thrown unless finished.

Add

  • Expose cache property from useSuspender hook for manual control over the internal cache. The cache has two properties: size and clear. This feature is experimental and not documented yet!

All changes: v1.1.0...v2.0.0-beta.0

1.1.0

18 Jun 14:09
Compare
Choose a tag to compare

Update

  • Improved TS typings - the result of SuspenderHook function will be the same as SuspenderImplementation you provided (for example, if your SuspenderImplementation function returns User type, then SuspenderHook will also return User type instead of any).
  • Add exports section, so this package can be used with both CJS and ESM in Node.js. The next major release will be ESM only.

All changes: v1.0.0...v1.1.0

1.0.0

13 Feb 17:28
Compare
Choose a tag to compare

Add

  • Add a new TypeScript typings

Update

  • Overall package improvements
  • Stabilise public API for the first major release

All changes: v0.4.2...v1.0.0

0.4.2

14 Apr 00:10
Compare
Choose a tag to compare

Remove

  • Remove TS typings in favour of JSDoc

All changes: v0.4.1...v0.4.2

0.4.1

10 Apr 21:16
Compare
Choose a tag to compare

Add

  • TypeScript support

Update

  • Improve JSDoc

All changes: v0.4.0...v0.4.1

0.4.0

31 Mar 19:03
Compare
Choose a tag to compare

Update

  • BREAKING: Rename useSuspender.init() -> useSuspender.callEarly()

Add

  • useSuspender hook will compare taken arguments with the previous, then execute the suspender function when they aren't the same. This will also cancel the previous operation.

All changes: v0.3.1...v0.4.0

0.3.1

26 Mar 22:48
Compare
Choose a tag to compare

Update

  • Improvements for library's internal code. Nothing really changed or updated for public API or behaviour.

All changes: v0.3.0...v0.3.1

0.3.0

15 Feb 01:14
Compare
Choose a tag to compare

Add

  • createSuspenser now takes second argument: ctx. It allows to set a thisArg for each useSuspender() call. This argument can be overwritten using Function#{call,apply,bind} methods on any particular useSuspender() call.
import createSuspender from "use-suspender"

import User from "./api/User"

const useSuspender = createSuspender(User.getUser, User)
  • useSuspender.init() allows to call useSuspender earcly (outside of a component render function),
    so that you can do something before your component will be actually called and rendered:
import creteSuspender from "use-suspender"
import React from "react"

const useSuspender = createSuspender(
  () => new Promise(resolve => setTimeout(() => resolve("Hello, world!"), 1000))
)

// Calls your suspender function
useSuspender.init()

function HelloComponent() {
  // Will return a result immediately if Promise returned by suspender function
  // has been fulfilled before HelloComponent call.
  const text = useSuspender()

  return <div>{text}</div>
}

The init() and useSuspender() functions can be used separately:

import creteSuspender from "use-suspender"
import React from "react"

const {useSuspender, init} = createSuspender(
  () => new Promise(resolve => setTimeout(() => resolve("Hello, world!"), 1000))
)

All changes: v0.2.0...v0.3.0

0.2.0

09 Feb 23:33
Compare
Choose a tag to compare

Update

  • Improve error handling for regular functions.

All changes: v0.1.0...v0.2.0

Initial release

08 Feb 23:16
Compare
Choose a tag to compare
v0.1.0

Fix for .npmignore