0.0.12 • Published 1 year ago

@orcsrvcs/remote-api-core v0.0.12

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
1 year ago

Remote API Core

EventHander is the primary object of this package. It handles the passing and receiving of events. To ensure an event reaches only its desired destination, the event relies on information about its app, its remote, and an optional unique identifier.

Using the API Core

Auto-generated Documentation

For the convenience of possibly extending this package to not exclusively rely on events, EventHandler is renamed as Api to abstract away from the remote which technique is used. EventHandler will be instantiated new Api() with attributes specific to the remote supporting these events, and publish() and subscribe() will be called to send and receive events.

interface EventOne {
  value: string,
  success: () => void
};

const eventOne = {
  name: 'eventOne',
  direction: Direction.BOTH,
  version: 1,
  convertToOtherVersion: (response: EventOne, otherVersion: number): any => {
    // Convert response from the current supported structure to a structure supported by otherVersion
    return response;
  },
  convertToLocalVersion: (response: any, otherVersion: number): EventOne => {
    // Convert response from the otherVersion structure to the current supported structure
    return response;
  }
};

const remoteType = {
  name: 'remoteName',
  events: [
    eventOne
  ]
};

const remoteApi = new Api(AppType.SHELL, 'appName', remoteType);

remoteApi.publish(
  eventOne,
  {
    value: 'someValue',
    success: () => {
      // Do stuff with callback
    }
  }
);

remoteApi.subscribe(
  eventOne,
  (event: EventOne) => {
    // Do stuff with event
  }
);

remoteApi.connect();
0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago