Numerous Philanthropic Misanthropes
Wondering what’s next for npm?Check out our public roadmap! »

@olenbetong/data-object

0.3.1 • Public • Published

Appframe Data for modern browsers

An implementation of afDataObject using modern browser APIs and syntax. The bundle also includes the Api, DataProviderHandler, MemoryStorage and Procedure classes.

API changes

This project provides 2 versions of the data object. One version that should have the same API as afDataObject (but might not be compatible), and one slightly more lightweight version.

The light version removes some of the less used methods:

  • bulkDestroy
  • bulkInsert
  • getAllPrimKeys
  • getAllRows
  • getByID
  • getDataHandler
  • getDataSourceArticleID
  • getDirtyData
  • getEventHandler
  • getPagingComponent
  • getSystemFieldNames
  • getGroupBy / setGroupBy
  • hasIITrig
  • hasIUTrig
  • hasIDTrig
  • saveToLocal
  • saveToIndexedDB
  • setErrorHandler

Async

Functions that takes callbacks are now simple wrappers around equivalent async functions. The async functions are preferred over functions with callbacks, and the callback functions might be deprecated/removed in the future. The async versions do not use the errorHandler, but will isntead throw errors.

Async methods in DataObject:

  • deleteCurrentRowAsync
  • deleteRowAsync
  • endEditAsync
  • refreshCurrentRowAsync
  • refreshDataSourceAsync
  • refreshRowAsync
  • retrievePartialAsync
  • saveAsync

Async methods in DataHandler:

  • createAsync
  • destroyAsync
  • retrieveAsync
  • updateAsync

Async methods in Procedure

  • executeAsync
  • execute2Async

Other differences

  • Abortable events may now return a promise. If it resolves to false, the action will be cancelled.
  • These properties are public on the data object
    • Options (dataObject.options)
    • Data handler (dataObject.dataHandler)
    • Event handler (dataObject.eventHandler)
    • storageEngine (dataObject.storageEngine)
    • masterDataObject (dataObject.masterDataObject)

Breaking changes

  • beginEdit and setCurrentIndex are now async (due to supporting promises in abortable events)
  • save, setCurrentIndex and endEdit no longer support running synchronously by passing a synchronous boolean parameter. setCurrentIndex still supports a second boolean parameter, but this will not cause it to run synchronously, but instead only await the save call if it is true.

Polyfills

The following APIs need to be polyfilled in order to use this project with older browsers, e.g. IE 11:

  • fetch + AbortController
  • Promise
  • Array.prototype.includes
  • Object.assign
  • Object.values
  • String.prototype.includes

With even more polyfills, the project might be usable in older browsers than IE11, but if you need to support those, you might be better off with the original afDataOBject.

polyfill.io

https://polyfill.io/v3/polyfill.min.js?flags=gated&rum=true&features=fetch%2CAbortController%2Cdefault%2CArray.prototype.includes%2CObject.values

Keywords

none

Install

npm i @olenbetong/[email protected]

Version

0.3.1

License

MIT

Unpacked Size

1.69 MB

Total Files

196

Last publish

Collaborators

  • avatar