Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexaegis/svelte-rxjs-observer
A simple typesafe observer component for svelte
https://github.com/alexaegis/svelte-rxjs-observer
javascript library npm observable observer rxjs subscribe svelte sveltejs typescript
Last synced: 3 months ago
JSON representation
A simple typesafe observer component for svelte
- Host: GitHub
- URL: https://github.com/alexaegis/svelte-rxjs-observer
- Owner: AlexAegis
- License: mit
- Created: 2022-10-04T19:11:18.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T15:12:52.000Z (8 months ago)
- Last Synced: 2024-10-01T02:44:15.950Z (3 months ago)
- Topics: javascript, library, npm, observable, observer, rxjs, subscribe, svelte, sveltejs, typescript
- Language: Svelte
- Homepage: https://alexaegis.github.io/svelte-rxjs-observer/
- Size: 1.13 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- Funding: .github/funding.yml
- License: license
Awesome Lists containing this project
README
# [svelte-rxjs-observer](https://github.com/AlexAegis/svelte-rxjs-observer#readme)
[![npm](https://img.shields.io/npm/v/svelte-rxjs-observer/latest)](https://www.npmjs.com/package/svelte-rxjs-observer)
[![ci](https://github.com/AlexAegis/svelte-rxjs-observer/actions/workflows/cicd.yml/badge.svg)](https://github.com/AlexAegis/svelte-rxjs-observer/actions/workflows/cicd.yml)
[![codacy](https://app.codacy.com/project/badge/Grade/c2f27ff062b74be1a141e215bdd39fcb)](https://app.codacy.com/gh/AlexAegis/svelte-rxjs-observer/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![codecov](https://codecov.io/github/AlexAegis/svelte-rxjs-observer/branch/master/graph/badge.svg?token=MUyY3RXTqa)](https://codecov.io/github/AlexAegis/svelte-rxjs-observer)
[![vercel](https://vercelbadge.vercel.app/api/alexaegis/svelte-rxjs-observer)](https://vercel.com/alexaegis/svelte-rxjs-observer)A tiny component that observes observables for you
[Example app available @ Vercel](https://svelte-rxjs-observer.vercel.app/)
## Usage
Install:
```sh
npm install svelte-rxjs-observer
```## Examples
### Simple
```svelte
import { Subject } from 'rxjs';
import { Observer } from 'svelte-rxjs-observer';let subject = new Subject<number>();
{next}
loading...```
### Typed error and completion states
```svelte
import { Subject } from 'rxjs';
import { Observer } from 'svelte-rxjs-observer';let subject = new Subject<number>();
let errorType: TypeError; // Optinal typehint for the error{stringify({ next })}
{stringify({ slot: 'pending' })}
{stringify({ slot: 'error', error: { message: error.message }, last })}
{stringify({ slot: 'completed', last })}
```