Skip to content

drinkingChai/mod-bank

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

ModBank

A html module and front end databank. Modules can modify the data in the front end and the bank will update all related modules.

requires: jQuery

Getting Started


Download the ModBank.js and include it in your html file

<script src="js/ModBank.js" charset="utf-8"></script>

Concept


Store

  • stores data in banks
  • attach modules to banks
  • when bank update is triggered via setData, will call update on all modules

Module

  • can be attached to multiple banks in store
  • update calls render

Use


Module Extend this class like this:

class NewMod extends Mod {
  constructor(id, store, ...bankNames) {
    super(id, store, ...bankNames)
  }
}

Change the render function for your module Call setData with the updated data anywhere

Example:

render() {
  let store = this.store
  this.$html = $(`<button></button>`)
  this.$html.on('click', 'button', function() {
    store.setData('bankName', newData)
  })
}

Examples in the demo branch.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published