0.1.6 • Published 2 years ago

simple-eventhubs-framework v0.1.6

Weekly downloads
17
License
MIT
Repository
github
Last release
2 years ago

Provided is an Event Beacon as

import { EventBeacon } from 'simple-eventhubs-framework';

const beacon = new EventBeacon();

const myListener = async event => {

    const {
        action,
        transaction_id,
        payload
    } = event;    
};

EventBeacon.register

register callbacks

props the keyword argument object

props.hub string the eventhub to unregister the listener

props.callback Function the specific callback to unregister (optional), default: Any/All

props.action string the action to unregister callbacks for, default Any/All

props.transaction_id string the transactionId to unregister callbacks for, default Any/All.

props.consumerGroup string the consumergroup of the subscription, default "$Default"

props.once boolean when an acceptable event has been received, shut this down/unregister this listener.

Returns Promise resolved by boolean true on success

const myCallbackFn = event => { ....custom event handler code..... }

await myBeaconInstance.register({
    hub: "myHub",
    action: "my-action",
    consumerGroup: "myConsumer",
    transaction_id: "some_specific_transaction_were_interested_in",
    once: true, // unregister once this event has been received and callback fired.
    callback: myCallbackFn
})

EventBeacon.unregister

Unregister callbacks

props the keyword argument object

props.hub string the eventhub to unregister the listener

props.callback Function the specific callback to unregister (optional), default: Any/All

props.action string the action to unregister callbacks for, default Any/All

props.transaction_id string the transactionId to unregister callbacks for, default Any/All.

props.consumerGroup string the consumergroup of the subscription, default "$Default"

Returns Promise resolved by boolean true on success

const myCallbackFn = event => { ....custom event handler code..... }

await myBeaconInstance.unregister({
    hub: "myhub",
    action: "my-action",
    transaction_id: "saf87-asdf897asf-asdf89asdf-sadf",
    consumerGroup: "$Default",
    callback: myCallbackFn
});

EventBeacon.dispatch

Dispatch an event

props the keyword argument object

props.hub string the eventhub to unregister the listener

props.action string the action to unregister callbacks for, default Any/All

props.transaction_id string optional tracking id for this event

props.payload object key/prop object for this event - must be JSON friendly (ie not cyclic, all key vals are primitives and not functions etc)

Returns Promise resolved by boolean true on success

const result = await MyBeaconInstance.dispatch({
    hub: "myhub",
    action: "my-action"
    payload: {
        this: "that"
    }
})
0.1.6

2 years ago

0.1.5

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago