3.0.0 • Published 5 years ago

@honkjs/honk v3.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 years ago

Honk, pronounced "HONK 🚚 HONK" shouted as loudly as possible while making a truck horn pulling motion, is inspired by, and a loud collection of addons for, choo 🚂🚋, the sturdy frontend framework that could.

"Honk", because, by default, that is all that it does.



Getting started

npm install @honkjs/honk
import Honk from '@honkjs/honk';

const honk = new Honk().honk;

honk(); // output: "HONK 🚚 HONK"

Would you like to know more?

With service injection (thunks)

import Honk from '@honkjs/honk';
import injector from '@honkjs/injector';

const honk = new Honk().use(injector()).honk;

honk(); // output: "HONK 🚚 HONK"

function delayedHonk(delay: number) {
  return function({ honk }: IHonkServices) {
    setTimeout(() => honk(), delay);
  };
}

honk(delayedHonk(1000)); // output after 1000ms: "HONK 🚚 HONK"

Would you like to know more?

With custom services

import Honk from '@honkjs/honk';
import injector from '@honkjs/injector';

const honk = new Honk()
  .use(injector({ time: 100 }))
  .honk;

honk(); // output: "HONK 🚚 HONK"

function honkOne({ honk, time }) {
  setTimeout(() => honk(), time);
}

honk(honkOne); // output after 100ms: "HONK 🚚 HONK"

Would you like to know more?

With custom middleware

import Honk from '@honkjs/honk';

function honkingMiddleware(app, next) {
  return function(args) {
    if (args.length === 1 && args[0].type) {
      const honkType = args[0].type;
      if (honkType === 'quiet') {
        return 'honk 🚚 honk';
      } else {
        return 'HONK 🚚 HONK';
      }
    }
    return next(args);
  };
}

const honk = new Honk().use(honkingMiddleware).honk;

honk(); // output: "HONK 🚚 HONK"

const quiet = honk.honk({ type: 'quiet' }); // output: nothing.
// quiet = "honk 🚚 honk"

const loud = honk.honk({ type: 'loud' }); // output: nothing.
// loud = "HONK 🚚 HONK"

Would you like to know more?

With silence

import Honk from '@honkjs/honk';
import silence from '@honkjs/silence';

const honk = new Honk().use(silence()).honk;

honk(); // output: Nothing. Just the silence of your cold, dead heart.

Would you like to know more?

FAQ

Honk?

HONK 🚚 HONK