Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jill64/svelte-observer
🔠Library for Svelte to make Promise status easily observable from outside
https://github.com/jill64/svelte-observer
observer promise svelte
Last synced: 7 days ago
JSON representation
🔠Library for Svelte to make Promise status easily observable from outside
- Host: GitHub
- URL: https://github.com/jill64/svelte-observer
- Owner: jill64
- License: mit
- Created: 2024-12-27T23:09:12.000Z (8 days ago)
- Default Branch: main
- Last Pushed: 2024-12-28T00:40:55.000Z (8 days ago)
- Last Synced: 2024-12-28T00:42:03.688Z (8 days ago)
- Topics: observer, promise, svelte
- Language: TypeScript
- Homepage: https://svelte-observer.jill64.dev
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @jill64/svelte-observer
🔠Library for Svelte to make Promise status easily observable from outside
## [Demo](https://svelte-observer.jill64.dev)
## Installation
```bash
npm i @jill64/svelte-observer
```## Usage
```svelte
import { observable } from '@jill64/svelte-observer'
// Define the asynchronous function you want to observe
const wait1Sec = async () => {
await new Promise((resolve) => setTimeout(resolve, 1000))
}
const wait1SecThrow = async () => {
await new Promise((resolve) => setTimeout(resolve, 1000))
throw new Error('Expected Error')
} // Create Proxylet { status, observed } = $derived(observable())
// Define proxied functions
let observedWait1Sec = $derived(observed(wait1Sec))
let observedWait1SecThrow = $derived(observed(wait1SecThrow))Success
Error
{status}
```## License
[MIT](LICENSE)