1.4.7 • Published 1 year ago

@dialob/fill-api v1.4.7

Weekly downloads
62
License
Apache-2.0
Repository
-
Last release
1 year ago

Dialob Fill API

Install

yarn add @dialob/fill-api

Quick-start

import DialobFill from '@dialob/fill-api';

// Replace `sessionId` and `endpoint` with appropriate values
const sessionId = '8bab410b7bfac6f64fbbb1024d52a96f';
const session = DialobFill.newSession(sessionId, {
  endpoint: 'https://instance.dialob.io/',
});

// Now you have a session object that holds the state of the session. You should first pull data
// from the server
session.pull();

// Update answer
session.setAnswer('itemId', 'newAnswer');

// Add row to row group
session.addRowToGroup('rowGroup1');

// Delete row from row group
session.deleteRow('rowGroup1.1');

// Next page
session.next();

// Previous page
session.previous();

// Go directly to a page
session.goToPage(pageId);

// Complete the session
session.complete();

// Get item
session.getItem(itemId);

// Get item errors
session.getItemErrors(itemId);

// Get valueSet
session.getValueSet(valueSetId);

// Get locale
session.getLocale();

// Set locale
session.setLocale(locale);

// Get context or expression variable value
session.getVariable(id);

// The session object batches updates and syncs them at appropriate times, however, it also updates
// its local cache instantly. The `update` event is emitted on any state change, local or remote.
session.on('update', () => {
  console.log('onUpdate');
});

// `sync` event is emitted when syncing starts or ends.
session.on('sync' (syncState) => {
  // `syncState` can be either `INPROGRESS` (syncing is ongoing) or `DONE` (syncing was successfully
  // completed)
  console.log('onSync', syncState);
});

// `error` event is emitted if some error happens that can't be handled by the library
session.on('error', (type, error) => {
  // `type` is either `SYNC` (sync error) or `SYNC-REPEATED` (repeated sync error, indication of systematic failure and should require user interaction)
  console.error(type, error);
});

// You can remove listeners with `removeListener()`
session.removeListener('update', updateFn);

Session options

You can define session options as the third argument to the session constructor:

const session = DialobFill.newSession(sessionId, transport, options);

The possible options are:

interface SessionOptions {
  // Defines how many milliseconds session should batch actions for before syncing them to server.
  // A value of -1 disables the batching logic and always immediately syncs each action. This can
  // be used if you want to do debouncing yourself, for example.
  syncWait?: number;
}

Compatibility

This API does not follow the same versioning as Dialob backend. To ensure full compatibility, refer to this table. Each row documents a compatibility change, any versions in between can be assumed to be compatible with eachother.

fill-apibackend
1.4.01.0.11
1.3.01.0.8
1.0.01.0.0
1.4.7

1 year ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago