From 60d2e6d422c2fd1dc0d49274ebcd57b587afa1bb Mon Sep 17 00:00:00 2001 From: BernhardBaumrock Date: Fri, 18 Oct 2024 21:20:08 +0200 Subject: [PATCH] feat!: bump version --- README.md | 6 ++-- docs/examples.js | 74 ------------------------------------------------ 2 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 docs/examples.js diff --git a/README.md b/README.md index a32319f..bfde722 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -# RockJavaScriptHooks (EXPERIMENTAL) +# RockJavaScriptHooks -# !!! PLEASE USE THIS MODULE ONLY FOR TESTING AT THE MOMENT - API CHANGES ARE ALREADY ON THE DEV BRANCH AND MORE WILL COME !!! I guess I'll have something usable in 11/2024 😎 - -Please see docs folder! +Please read the docs at [baumrock.com/RockJavaScriptHooks](https://www.baumrock.com/RockJavaScriptHooks) diff --git a/docs/examples.js b/docs/examples.js deleted file mode 100644 index 9237a2f..0000000 --- a/docs/examples.js +++ /dev/null @@ -1,74 +0,0 @@ -class HelloWorld { - ___greet(salut = "hello", what = "world") { - return `${salut} ${what}`; - } -} - -const helloWorld = ProcessWire.wire(new HelloWorld()); - -// shows hello world -console.log(helloWorld.greet()); - -// shows hi there -console.log(helloWorld.greet("hi", "there")); - -// add BEFORE hook -ProcessWire.addHookBefore("HelloWorld::greet", (event) => { - event.arguments(0, "hallo"); - event.arguments(1, "welt"); -}); - -// shows hallo welt -console.log(helloWorld.greet()); - -// shows hallo welt -console.log(helloWorld.greet("servas", "oida")); - -// add AFTER hook -ProcessWire.addHookAfter("HelloWorld::greet", (event) => { - // shows ['hallo', 'welt'] - console.log(event.arguments()); - event.return = "hi universe"; -}); - -// shows hi universe -console.log(helloWorld.greet()); - -console.log("----------- hook priority -----------"); - -class PrioDemo { - ___greet() { - return "hello world"; - } -} - -const prio = ProcessWire.wire(new PrioDemo()); - -ProcessWire.addHookAfter( - "PrioDemo::greet", - () => { - console.log("second"); - }, - 20 -); -ProcessWire.addHookAfter( - "PrioDemo::greet", - () => { - console.log("first"); - }, - 10 -); -ProcessWire.addHookAfter( - "PrioDemo::greet", - () => { - console.log("third"); - }, - 30 -); - -// shows -// first -// second -// third -// hello world -console.log(prio.greet());