Skip to content

capsidjs/capsid-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

capsid-module

This repository describes a capsid-module. (3rd party module for capsid)

  • A capsid module should specify capsid dependency as a peer dependency.
  • A capsid module should have capsidmodule keyword in keywords field of its package.json. (That should appear in this search)
  • A capsid module should expose install function.
  • The install function should have the following signature
install(capsid, options)

Where capsid is the capsid module and options are the object of arbitrary shape.

  • The install function may define a component (or components) using the given capsid.def method.
  • If the install function defines any component, then the names of them should be configurable through options. (It can have default names for components.)
  • A capsid module shouldn't require('capsid') directly in its source code. (Use the injected capsid object)
  • A capsid module should document the available options and their default values.

A typical module structure looks like the below:

exports.install = (capsid, options) => {

  const name = options.name || 'my-capsid-component'

  /**
   * MyComponent is responsible for ...
   */
  class MyComponent {
    __init__ () {
      // ... initializations ...
    }

    @capsid.on.click
    onClick () {
      // ... handling click event ...
    }

    @capsid.on('mouseover', { at: '.tooltip' })
    someReaction () {
      // ... handling mouseover event at .tooltip elements.
    }
  }

  capsid.def(name, MyComponent)
}

Usage of capsid-module

The consumer of a capsid-module should call capsid.install method:

const capsid = require('capsid')

capsid.install(require('3rd-party-capsid-module'), options)

The above should install 3rd-party-capsid-module with the give options.

Example of capsid-module

About

📜 The definition of `capsid module` 💊

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published