@epikodelabs/streamix / networking/src/public-api / jsonp
Function: jsonp()
jsonp<
T>(url,callbackParam?):Atom<T>
Defined in: projects/libraries/streamix/networking/src/lib/jsonp.ts:17
Creates a stream that performs a JSONP request and emits the resulting data once.
This function provides a reactive way to handle JSONP requests, which are often used to bypass the same-origin policy for loading data from a different domain. It dynamically creates a <script> tag, handles the response via a global callback, and then cleans up after itself. The stream emits a single value and then completes.
Type Parameters
T
T = any
The type of the JSONP data to be emitted.
Parameters
url
MaybePromise<string>
The URL to make the JSONP request to.
callbackParam?
MaybePromise<string> = 'callback'
The name of the query parameter for the callback function.
Returns
Atom<T>
A new atom that emits the JSONP data and then completes.