@olenbetong/data-object
ES6+ implementation of af.DataObject and af.Procedure
Last updated a year ago by bjornarvh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @olenbetong/data-object 
SYNC missed versions from official npm registry.

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 (dataHandler field on DataObject is public)
  • getDataSourceArticleID (options field on DataObject is public)
  • getDirtyData
  • getEventHandler (eventHandler field on DataObject is public)
  • 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
  • getAllPrimKeysAsync (compat version only)
  • refreshCurrentRowAsync
  • refreshDataSourceAsync
  • refreshRowAsync
  • retrievePartialAsync
  • saveAsync

Async methods in DataHandler:

  • createAsync
  • destroyAsync
  • retrieveAsync
  • updateAsync

Async methods in Procedure

  • executeAsync
  • execute2Async

Other differences

  • 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

  • XML fields not supported. Will be handled as strings
  • 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 will return a promise if it is set to true.

Event handler changes

To reduce dependency size, the EventHandler class from @olenbetong/common has been replaced with mitt. Events emitted are CustomEvent instances, and instead of returning false to abort an event, we have to call event.preventDefault() instead. The arguments for the event are now found in event.detail.

Another consequence of using mitt is that all event handlers will be called even if one of them calls event.preventDefault(). This shouldn't be a problem, since relying on the event handler to stop executing is unsafe, because you don't know if a handler after yours will abort the event.

The Paging component used another EvenHandler type, but this has also been replaced with mitt. This means you no longer have an on, before or afterstring as the first argument to attach and detach. To replace the after events for abortable events, afterPageRefresh and afterPageChange have been added.

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

Current Tags

  • 0.7.9                                ...           latest (8 days ago)

24 Versions

  • 0.7.9                                ...           8 days ago
  • 0.7.8                                ...           8 days ago
  • 0.8.0-alpha.0                                ...           7 months ago
  • 0.7.7                                ...           7 months ago
  • 0.7.6                                ...           8 months ago
  • 0.7.5                                ...           8 months ago
  • 0.7.4                                ...           8 months ago
  • 0.7.3                                ...           8 months ago
  • 0.7.2                                ...           8 months ago
  • 0.7.1                                ...           8 months ago
  • 0.7.0                                ...           8 months ago
  • 0.6.0                                ...           8 months ago
  • 0.5.0                                ...           10 months ago
  • 0.4.2                                ...           a year ago
  • 0.4.1                                ...           a year ago
  • 0.4.0                                ...           a year ago
  • 0.3.1                                ...           a year ago
  • 0.3.0                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 17
Last Day 0
Last Week 17
Last Month 0
Dependencies (8)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |