Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
observableCallback
✓ import { observableCallback } from 'observable-callback'
✗ const observableCallback = require('observable-callback')
Package is ESM-only; named import required. CommonJS require will fail unless using a bundler that handles ESM.
Observable
✓ import { Observable } from 'rxjs'
✗ import { Observable } from 'observable-callback'
Observable type is not re-exported; must be imported from rxjs.
OperatorFunction
✓ import { OperatorFunction } from 'rxjs'
✗ import { OperatorFunction } from 'observable-callback'
OperatorFunction type used in the overloaded signature; import from rxjs.
Shows creation of observable-callback, subscription, invoking callback, and usage with operator and in React.
import { observableCallback } from 'observable-callback';
import { map } from 'rxjs/operators';
// Basic usage: create callback and observable
const [value$, onValue] = observableCallback();
value$.subscribe(value => console.log(value)); // logs 'Hi'
onValue('Hi');
// With operator: transform stream
const [greeting$, onPlanet] = observableCallback(
planet$ => planet$.pipe(map(planet => `Hello ${planet}!`))
);
greeting$.subscribe(console.log); // logs 'Hello world!'
onPlanet('world');
// React example
import React from 'react';
const [clicks$, onClick] = observableCallback();
clicks$.subscribe(() => console.log('clicked'));
const Button = () => <button onClick={onClick}>Click me</button>;
Errors
Common errors & fixes
Cannot find module 'observable-callback' or its corresponding type declarations.
The package may not be installed or TypeScript cannot resolve it due to missing node_modules or incorrect moduleResolution.
fixRun npm install observable-callback. Ensure tsconfig has moduleResolution: 'node' or 'node16' and esModuleInterop true.
Module not found: Error: Can't resolve 'observable-callback'
CommonJS require used in a bundler that cannot resolve ESM-only package.
fixUse import syntax or configure bundler to handle ESM (e.g., webpack with experiments.outputModule).
TypeError: observableCallback is not a function
Incorrect import style: using default import or destructuring from wrong object.
fixUse named import: import { observableCallback } from 'observable-callback'. Audit
Dependencies
rxjsrequiredPeer dependency for Observable and Subject types. Must be installed separately.