Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Importing ActiveJS

Jordan Langton edited this page Jul 21, 2020 · 1 revision

In order to access some of the features the ActiveJS provides, you will need to import ActiveJS from the packages folder if you are inside of your app entry point. If you are in a view, the ActiveJS global variable will be avaliable to you. See example below to see what you can access from the import/global variable:

import * as ActiveJS from "@jordan_langton/activejs";
// or
ActiveJS.(whatever property you want to access)
  • ActiveJS (Config) back to top

    import { Config } from "@jordan_langton/activejs";
    
    // An object with all your initial config data inside
    Config = {
      "name": "TESTING Application",
      "version": "1.0.0",
      "environment": "Development",
      "description": "This is a test application",
      "systemTheme": "project-theme",
      "systemStyles": ['messages', 'anamations', 'views', 'fonts'],
      "interfaces": [],
      "store": Store, // if you passed a global store to ActiveJS
      "routes": []
    }
  • ActiveJS (State) back to top

    import { State } from "@jordan_langton/activejs";
    
    // An object with all your State methods and global state
    State = {
      model: {},
      Get(propName="", payload) {},
      Commit(name="", payload) {},
      Dispatch(name="", payload, callback=()=>{}) {}
    }
  • ActiveJS (Emit) back to top

    import { Emit } from "@jordan_langton/activejs";
    
    // A method used to 'emit' some sort of data
    Emit(eventName="", payload=true);
  • ActiveJS (Accept) back to top

    ```js
    import { Accept } from "@jordan_langton/activejs";
    
    // A method used to 'accept' data emited from somewhere in your app
    Accept(eventName="");
    ```
    
  • ActiveJS (Component) back to top

    import { Component } from "@jordan_langton/activejs";
    
    // A class where you define a new component
    export default class testComp extends Component {
    
      constructor(props) {
        // Always call super passing props from the constructor
        super(props, {
          anyExtraData: false
        });
      }
    
      // this is a life cycle method
      compMounted() {    
        console.log(this.$props);    
        console.log(this.$extraData);    
        this.render(`<h1>${this.$props.message}</h1>`);
      }
    
    }
  • ActiveJS (reqisterComponent) back to top

    import { reqisterComponent } from "@jordan_langton/activejs";
    
    // A method used to a component to ActiveJS to use in your views
    reqisterComponent(reference="", component={});
  • ActiveJS (saveToCache) back to top

    import { saveToCache } from "@jordan_langton/activejs";
    
    // A method used to cache some data on the device
    saveToCache(key="", payload={});
  • ActiveJS (getFromCache) back to top

    import { getFromCache } from "@jordan_langton/activejs";
    
    // A method used to get something out of your device cache
    getFromCache(key="");
  • ActiveJS (createApp) back to top

    import { createApp } from "@jordan_langton/activejs";
    
    // This is what you call to initialize your ActiveJS application
    createApp(configuration={}, Created=() => {});
  • ActiveJS (Router) back to top

    import { Router } from "@jordan_langton/activejs";
    
    // An object with router specific methods
    Router = {
      navBack: () => {},
      removeLastCrumb: () => {},
      route: (path="", params=null) => {},
      addCrumb: (crumb={path: "", params: null}) => {},
    }
  • ActiveJS (newController) back to top

    // This is what you call to initialize a new controller for a view
    ActiveJS.newController(View_Name="", Controller={
      el: '',
      props: [], 
      Data() {}, 
      _Mounted() {}, 
      _Rendered() {}, 
      _beforeUpdate() {}, 
      _Updated() {}, 
      observers: {}, 
      computed: {}, 
      methods: {}
    });
  • ActiveJS (use) back to top

    // This is what you call to add a library you want to use in your views
    ActiveJS.use(key="", library={});