@teambit/harmony
TypeScript icon, indicating that this package has built-in type declarations

0.4.6 • Public • Published

Harmony

Harmony is the engine that drives Bit extensibility and composability. It's an abstract extension system indended to make any software extendable and composable.

Harmony takes a "micro-kernel" approach and implements the near-minimum amount of software required to build any JavaScript system from independent components through composition.

Installation

$ bit install @teambit/harmony

Quick start

import { Harmony, Extension } from 'harmony';

@Extensioin
class Person {
  sayHello(name = 'world') {
    return `hello ${name}!`;
  }
}

const person = Harmony.load(Person); 
helloWorld.sayHello(); // returns 'hello world!'

Component composition

DI

class Dude {
  constructor(
    private person: Person
  ) {}

  sayHello() {
    return this.person.sayHello('dude');
  }
};

Harmony.load([Dude]).sayHello(); // echos 'hello dude!'

Hooks

@Extension()
class CLI {
  // @hook('command') commands = Hook.create<Command>();
  static command() {
    return Hook.create<Command>();
  }

  run() {
    const allCommands = this.commands.list(); // outputs all hook subscribers
  }
} 

@Extension()
class Compiler {
  
  @command()
  main() {
    return {
      synopsis: 'compile <path>',
      render: () => <Box></Box>
    };
  }
}

Extension configuration

Extension metadata

API reference

License

Apache License, Version 2.0

Made with to open software by Team Bit.

Package Sidebar

Install

npm i @teambit/harmony

Weekly Downloads

3,740

Version

0.4.6

License

Apache-2.0

Unpacked Size

230 kB

Total Files

251

Last publish

Collaborators

  • learn-bit
  • teambit-owner
  • shohamgilad
  • davidfirst
  • lalybar
  • ranm8
  • odedre
  • guysaar
  • itaymendel
  • erezbit
  • joshk2
  • redigma
  • yona007
  • jonisar
  • ocombe