https://github.com/d8corp/watch-state-utils
Utils to use watch-state
https://github.com/d8corp/watch-state-utils
Last synced: 6 months ago
JSON representation
Utils to use watch-state
- Host: GitHub
- URL: https://github.com/d8corp/watch-state-utils
- Owner: d8corp
- License: mit
- Created: 2021-05-29T10:02:54.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-11-02T20:53:10.000Z (8 months ago)
- Last Synced: 2025-11-02T22:14:26.910Z (8 months ago)
- Language: JavaScript
- Size: 134 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @watch-state/utils
[](https://www.npmjs.com/package/@watch-state/utils)
[](https://www.npmtrends.com/@watch-state/utils)
[](https://github.com/d8corp/watch-state-utils/actions/workflows/node.js.yml)
[](https://changelogs.xyz/@watch-state/utils)
[](https://github.com/d8corp/watch-state-utils/blob/main/LICENSE)
## Index
## Overview
`@watch-state/utils` is a utility package for [watch-state](https://github.com/d8corp/watch-state).
[](https://github.com/d8corp/watch-state-utils/stargazers)
[](https://github.com/d8corp/watch-state-utils/watchers)
## Index
[Install](#install) • [use](#use) • [inject](#inject)
## Install
###### [🏠︎](#index) / Install
To get started with this package, run the following command:
```shell
npm i @watch-state/utils
```
## use
###### [🏠︎](#index) / use
The `use` function helps you retrieve the current value from an observable.
```shell
import { State } from 'watch-state'
import { use } from '@watch-state/utils'
const name = new State('Mike')
console.log(use(name)) // 'Mike'
```
## inject
###### [🏠︎](#index) / inject
The `inject` function allows you to transform observable value using a callback.
```shell
import { State } from 'watch-state'
import { inject } from '@watch-state/utils'
const name = new State('Mike')
console.log(inject('Mike', name => `Name: ${name}`)) // 'Name: Mike'
console.log(inject(name, name => `Name: ${name}`)) // () => 'Name: Mike'
```
## Links
You can find more tools [here](https://www.npmjs.com/search?q=%40watch-state)
## Issues
If you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/watch-state-utils/issues)
[](https://github.com/d8corp/watch-state-utils/issues)