Skip to content

v1.2

Latest

Choose a tag to compare

@jamesgpearce jamesgpearce released this 27 Apr 21:28
· 25 commits to main since this release

This is a major release that includes reactivity and an optional module of React bindings.

Manager listeners

There is now a set of new Manager methods that can add listeners for various events. These include:

In all cases, the delListener method should be used to unregister the listener when it is no longer needed.

React bindings

Building on the basic bindings in the previous release, this release adds a set of hooks to benefit from the Manager's reactivity. These include:

In all cases, these hooks operate on the Manager registered in the Provider component so that one Manager can be used consistently throughout the application, something like this:

import {
  Provider,
  useCreateManager,
  useScheduleTaskRunCallback,
  useSetTask,
} from 'tinytick/ui-react';

const App = () => (
  <Provider manager={useCreateManager(createManager)}>
    <Panel />
  </Provider>
);

const Panel = () => {
  useSetTask('ping', async () => await fetch('https://example.org'));
  return <Button />;
};

const Button = () => {
  const callback = useScheduleTaskRunCallback('ping');
  return <button onClick={callback}>Ping</button>;
};

More information and examples for these React features is in the ui-react module API documentation.

Have fun and let us know how it goes!