{"library":"observable-callback","title":"observable-callback","description":"A small RxJS utility (v1.0.3, stable) that creates a callback function which publishes its argument to an observable stream. It wraps an RxJS Subject and returns a tuple of the subject's observable and its next() function. Also supports an optional operator function to transform the observable. Minimal, no other dependencies besides RxJS 6.x or 7.x. Ideal for converting callback-based APIs (e.g., React event handlers) into observable streams.","language":"javascript","status":"active","last_verified":"Sat May 09","install":{"commands":["npm install observable-callback"],"cli":null},"imports":["import { observableCallback } from 'observable-callback'","import { Observable } from 'rxjs'","import { OperatorFunction } from 'rxjs'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { observableCallback } from 'observable-callback';\nimport { map } from 'rxjs/operators';\n\n// Basic usage: create callback and observable\nconst [value$, onValue] = observableCallback();\nvalue$.subscribe(value => console.log(value)); // logs 'Hi'\nonValue('Hi');\n\n// With operator: transform stream\nconst [greeting$, onPlanet] = observableCallback(\n  planet$ => planet$.pipe(map(planet => `Hello ${planet}!`))\n);\ngreeting$.subscribe(console.log); // logs 'Hello world!'\nonPlanet('world');\n\n// React example\nimport React from 'react';\nconst [clicks$, onClick] = observableCallback();\nclicks$.subscribe(() => console.log('clicked'));\nconst Button = () => <button onClick={onClick}>Click me</button>;","lang":"typescript","description":"Shows creation of observable-callback, subscription, invoking callback, and usage with operator and in React.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}