An Interest In:
Web News this Week
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
Monster 1.25.0 released
Today we released the latest edition of our Monster project. Monster is a collection of javascript classes that we need for daily work in our web projects.
Besides small helper functions and classes it also provides useful functions to enable reactive programming.
Monster is available via jsdelivr and npm.
Only the changes are described here. The full functionality can be found in the documentation.
Resource
We have added a new class to handle resources. Resources are external content such as scripts, data, or stylesheets.
These classes are usually used by the ResourceManager
.
The class takes care of creating the tags and monitors the load event.
ResourceManager
With the new class RessourceManager
scripts, styles and data can be included in an HTML page simply by specifying the URL.
// new Objectconst manager = new ResourceManager();// add resourcesmanager.addScript('/example.js');manager.addData('/example.json');manager.addStylesheet('/example.css');// insert the tags into the dommanager.connect();// wait for all resources to be loadedmanager.available().then(()=>{ // do something}).catch(e=>console.log(e))
Worker
The class Worker.Factory
provides two small helper functions to start workers by script and URL.
const factory = new Factory();const script = `console.log('Hello Monster!');`;const worker = factory.createFromScript(script);// terminate workerfactory.terminate(worker)
FocusManager
The FocusManager
bundles helpful functions for working with the focus. Besides an alias for the active element, there is a possibility to set the focus to the next or previous element and to save and reset the elements with the focus.
// new Objectconst manager = new ResourceManager();// Which element has the focus right nowmanager.getActive();// remember the current focusmanager.storeFocus();// focus on the next element // or if already at the end the first elementmanager.focusNext();// and back to the starting positionmanager.restoreFocus();
The FocusManager
can also be given a query so that only selected elements are focused to.
UUID
We have added a new class to create a version 4 (random) uuid.
console.log(new UUID);// 7111f7ca-5add-4947-828b-c3d9ae43eaf2
hope you enjoy it!
References
Original Link: https://dev.to/schukai/monster-1250-released-ic1
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To