Skip to the content.

Easily modularize your javascript application into cancelable components.

npm version GitHub version Tests

jFactory


| [Installation](https://github.com/jfactory-es/jfactory/blob/master/docs/ref-import.md) | [Documentation](https://github.com/jfactory-es/jfactory/blob/master/docs/ref-index.md) | |----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| [Playground](/jfactory/playground/) - [Starter Kit](https://github.com/jfactory-es/jfactory-starterkit)

Overview

Components can be extended from any Class, or more simply by using an Object Literal through the shortcut jFactory():

let component = jFactory("myComponent", {

  onInstall() {
    this.$domFetch("myDom", "asset.html", "body");
    this.$cssFetch("myCss", "asset.css");
  },

  onEnable() {
    this.$interval("myUpdater", 1000, () =>
      this.$fetchJSON("myRequest", "asset.json")
        .then(data => this.$log("updated", data))
    );
    this.$on("click", "#bt-switch", () => this.mySwitchHandler());
    this.$on("click", "#bt-close", () => this.myCloseHandler());
  },

  async mySwitchHandler() {
    await (this.$.states.enabled ? this.$disable() : this.$enable());
    this.$log(this.$.states.enabled);
  },

  myCloseHandler() {
    this.$uninstall();
  }

})

await component.$install();
await component.$enable();

Patterns

Library

jFactory is designed with powerful ES6 Classes:

Philosophy

Modular JavaScript

How to Contribute

jFactory is an Open Source project. Your comments, bug reports and code proposals are always welcome. This project is new and you can help a lot by spreading the word. Also consider adding a github star, as it seems very important for its visibility at this stage. Thank you for your contributions!