Introduction

Sqimitive.js – A Universal Primitive

Sqimitive.js is a minimalistic paradigm-agnostic building block for applications written in JavaScript (not necessary in-browser or DOM-related). It provides core infrastructure without much domain-specific logic that you can quickly develop thanks to its flexible API.

Sqimitive.js is under 20K (minified), sports documentation that is nearly a hundred pages long (printed A4), needs no transpilers (plain pre-ES6 JavaScript, IE 11+) and depends only on a compatible utility library (NoDash +15K, Underscore.js un: or LoDash) and, optionally, on jQuery jq: or Zepto (for Sqimitive\jQuery).

And it’s in public domain (unlicense.org).

from jqex

Example
var Task = Sqimitive.jQuery.extend({
  el: {tag: 'li'},

  _opt: {
    // Keep el appended to the parent's el.
    attachPath: '.',
    // Define the default attributes of Task:
    caption: '',
    done: false,
  },

  events: {
    // Update the visual presentation whenever any _opt changes:
    change: 'render',

    render: function () {
      this.el.text(this.get('caption'))
        .toggleClass('done', this.get('done'))
    },
  },

  elEvents: {
    // Listen for double clicks on this.el to change the done state:
    dblclick: function () {
      this.set('done', !this.get('done'))
    },
  },
})

// Create a parent container for our to-do items (Task's) which
// is placed into the DOM at $('#tasks'):
var list = new Sqimitive.jQuery({el: '#tasks'})

// Create a new item, add it to list's _children:
list.nest( new Task({caption: 'Ready steady go!'}) )
// ...append to list's el and render for the first time:
  .attach().render()

// Double click on Task's element in the window to change its
// className.

Resources

npm npm install sqimitive     bower bower install sqimitive

If you spot a typo – select the fragment and press Ctrl+Enter. Help us keep this memo free of vexatious mistakes! Powered by github.com/ProgerXP/Orphus.

Basic code conventions

Defined in: HELP.chem, lines 78-131 (54 lines)