-- Leo's gemini proxy

-- Connecting to theparanoidtimes.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

🦩

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 🇷🇸

-- Response ended

-- Page fetched on Fri May 10 00:45:16 2024