[go: up one dir, main page]

DEV Community

Cover image for Monster 1.25 released
Volker Schukai for schukai GmbH

Posted on • Edited on

Monster 1.25 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 Object
const manager = new ResourceManager();

// add resources
manager.addScript('/example.js');
manager.addData('/example.json');
manager.addStylesheet('/example.css');

// insert the tags into the dom
manager.connect();

// wait for all resources to be loaded
manager.available().then(()=>{
   // do something
}).catch(e=>console.log(e))

Enter fullscreen mode Exit fullscreen mode

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 worker
factory.terminate(worker)
Enter fullscreen mode Exit fullscreen mode

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 Object
const manager = new ResourceManager();

// Which element has the focus right now
manager.getActive();

// remember the current focus
manager.storeFocus();
// focus on the next element 
// or if already at the end the first element
manager.focusNext();
// and back to the starting position
manager.restoreFocus();

Enter fullscreen mode Exit fullscreen mode

The FocusManager can also be given a query so that only selected elements are focused to.

I18n Formatter

We have added a new class to create a new Formatter.

console.log(new UUID);
// ↦ 7111f7ca-5add-4947-828b-c3d9ae43eaf2
Enter fullscreen mode Exit fullscreen mode

hope you enjoy it!

References

Top comments (2)

Collapse
 
lucascardim profile image
LucasCardim • Edited

Hello! What a beautiful work! I'm a beginner software engineer and loved the project. There are a few mistakes on the text of your homepage, besides that, what a lovely site! Great work! How can we know for future (or actual) opportunities to work with you guys? Thx!

Collapse
 
volker_schukai profile image
Volker Schukai

Thank you for the nice comment and the hint. We are represented on all possible channels such as linkedin, twitter, or on the web. just take a look.