🦩

Address

Unknown

the paranoid times

How to use the konami-js library in a ClojureScript project

24 May 2020

Recently, konami-js library got included [1] in the CLJSJS project. This post will show how to include and use the konami-js library in your ClojureScript project. Since all packages from CLJSJS are pushed to Clojars we can include the konami library as a regular CLJS dependency.

This is the :dependency key Leiningen from project.clj file:

  :dependencies [[org.clojure/clojure "1.10.0"]
                 [org.clojure/clojurescript "1.10.520"]
                 [cljsjs/konami "1.6.3-0"]] ;; this is current version of the library

The library exposes only one variable which is an easter egg constructor. It accepts only one parameter, a function that will be called when the Konami code is inputted. The function represents the easter egg itself and it can do whatever is needed.

Hello world example is to display a message:

(ns konami-cljs.core
    (:require cljsjs.konami))

(def easter-egg (js/Konami. (fn [] (js/alert "Hello Konami code!"))))

As mentioned the argument function can do anything. For example, it can redirect you to a different (secret) page:

(def easter-egg (js/Konami. (fn [] (js/window.open "https://example.com"))))

Once defined the 'easter-egg' var can remain untouched.

=> Project repository

Happy easter egg planting!

=> [1] konami-js in CLJSJS

=> Home

--

theparanoidtimes@posteo.net

=> PGP | https://theparanoidtimes.org

Released under CC BY-SA

Made in 🇷🇸

Proxy Information
Original URL
gemini://theparanoidtimes.org/blog/2020/05/24/konami-cljsjs-how-to
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
177.615298 milliseconds
Gemini-to-HTML Time
0.354925 milliseconds

This content has been proxied by September (ba2dc).