BSB Developer Docs
Loading...
Searching...
No Matches
js_fetch.h File Reference

fetch() JS API implementation More...

#include "js_runner_i.h"
#include <m-deque.h>
#include <sized_buffer.h>

Go to the source code of this file.

Data Structures

struct  JsFetchEvent
 
struct  JsFetchDataEvent
 
struct  JsFetchFetch
 
struct  JsFetchSink
 
struct  JsFetchPromise
 
struct  JsFetchResponse
 
struct  JsFetch
 

Typedefs

typedef struct JsFetch JsFetch
 
typedef enum JsFetchEventType JsFetchEventType
 
typedef struct JsFetchEvent JsFetchEvent
 
typedef enum JsFetchDataEventType JsFetchDataEventType
 
typedef struct JsFetchDataEvent JsFetchDataEvent
 
typedef bool(* JsFetchDataSinkCallback) (JsFetch *instance, JsFetchDataEvent *event, void *callback_context)
 Data sink callback - called when there is new event.
 
typedef struct JsFetchFetch JsFetchFetch
 
typedef struct JsFetchSink JsFetchSink
 
typedef struct JsFetchPromise JsFetchPromise
 
typedef struct JsFetchResponse JsFetchResponse
 

Enumerations

enum  JsFetchEventType {
  JsFetchEventTypeInvalid , JsFetchEventTypeHeaders , JsFetchEventTypeRxData , JsFetchEventTypeError ,
  JsFetchEventTypeDone , JsFetchEventTypeThreadExit
}
 
enum  JsFetchDataEventType { JsFetchDataEventTypeInvalid , JsFetchDataEventTypeData , JsFetchDataEventTypeDone , JsFetchDataEventTypeError }
 

Functions

 M_DEQUE_DEF (DataEventQueue, JsFetchDataEvent, M_POD_OPLIST)
 
void js_setup_fetch (void)
 
void js_fetch_process_event (const JsFetchEvent *event)
 
bool js_fetch_set_data_sink (JsFetch *instance, JsFetchDataSinkCallback callback, void *callback_context)
 Set a data sink which receives incoming data chunks.
 
void js_fetch_data_sink_ready (JsFetch *instance)
 Indicate that a data sink is ready to receive new data.
 
bool js_fetch_cancel (JsFetch *instance)
 Cancel ongoing fetch activity.
 
void js_fetch_abort (JsFetch *instance)
 If fetch thread is running, indicate it to stop.
 

Variables

const jerry_object_native_info_t js_fetch_response_native_info
 

Detailed Description

fetch() JS API implementation

Typedef Documentation

◆ JsFetchDataSinkCallback

typedef bool( * JsFetchDataSinkCallback) (JsFetch *instance, JsFetchDataEvent *event, void *callback_context)

Data sink callback - called when there is new event.

Returns
true if event is consumed

Function Documentation

◆ js_fetch_abort()

void js_fetch_abort ( JsFetch * instance)

If fetch thread is running, indicate it to stop.

Parameters
instanceJsFetch instance

◆ js_fetch_cancel()

bool js_fetch_cancel ( JsFetch * instance)

Cancel ongoing fetch activity.

Parameters
instanceJsFetch instance

◆ js_fetch_data_sink_ready()

void js_fetch_data_sink_ready ( JsFetch * instance)

Indicate that a data sink is ready to receive new data.

Parameters
instanceJsFetch instance

◆ js_fetch_set_data_sink()

bool js_fetch_set_data_sink ( JsFetch * instance,
JsFetchDataSinkCallback callback,
void * callback_context )

Set a data sink which receives incoming data chunks.

Data sink, when set, has an exclusive access to data chunks through its callback. It is not possible to set another data sink.

Parameters
instanceJsFetch instance
callback_contextuser pointer to be passed to the callback
callbackif NULL, data sink is no more
Returns
true if data sink has been set, false if another data sink is or has already been active.