An implementation of afDataObject using modern browser APIs and syntax. The bundle also includes the Api, DataProviderHandler, MemoryStorage and Procedure classes.
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:
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:
Async methods in DataHandler:
Async methods in Procedure
endEditno longer support running synchronously by passing a synchronous boolean parameter.
setCurrentIndexstill 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.
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
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
afterstring as the first argument to attach and detach. To replace the after events for abortable events,
afterPageChange have been added.
The following APIs need to be polyfilled in order to use this project with older browsers, e.g. IE 11:
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.