Skip to content

Library-agnostic implementation of UI component hooks

License

Notifications You must be signed in to change notification settings

resolritter/cmphook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This experiment library aims to provide framework-agnostic hooks. Hooks are an approach for component's state and effect management (popularized by React) which is traditionally tied to the render lifecycle method of individual component node.

API usage

Tests should be using the full API.

See the app examples Mithril and React.

Motivation

When React issues a state update, all hooks are re-run and all components below in the hierarchy are diffed again. While this is not usually a problem, it might trigger expensive computations down the tree - those might not only intensive number-crunching tasks like one would imagine, but also, for instance, issuing synchronous DOM multiple times, which might stagger the UI when called repeatedly.

Therefore, it can be said the main motivation of Hooker is to provide the same state management model, but not tied to the runtime semantics of any specific framework. Hooks can be ran manually and their latest values will always be available through a reference, which might be assigned to a variable and retrieved at any time through an uniform get/set API.

Trivia

This library initially started during development of subscribed_props. There it was validated that those fine-grained updates could be achieved on React with subscriptions.

About

Library-agnostic implementation of UI component hooks

Topics

Resources

License

Stars

Watchers

Forks