@honkjs/honk
v3.0.0
Published
Honk, because, by default, that is all that it does.
Downloads
8
Readme
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"
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"
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"
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"
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.
FAQ
Honk?
HONK 🚚 HONK