Skip to content
/ honk Public

A simple, but loud, dispatch framework with middleware. 🚚 Your local delivery trunk of dispatchers.

License

Notifications You must be signed in to change notification settings

honkjs/honk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Honk

Honk, pronounced "🚚 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.

Package Version
@honkjs/honk npm version
@honkjs/injector npm version
@honkjs/store npm version
@honkjs/silence npm version

Built with 🀣 by Kel and contributors

Getting started

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

const honk = new Honk().honk;

honk(); // output: "🚚 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!"

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

honk(delayedHonk(1000)); // output after 1000ms: "🚚 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!"

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

honk(honkOne); // output after 100ms: "🚚 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!';
      } else {
        return '🚚 HONK!';
      }
    }
    return next(args);
  };
}

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

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

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

const loud = honk.honk({ type: 'loud' }); // output: nothing.
// loud = "🚚 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!