Developing mobile digital key applications with ClojureScript

Developing mobile digital key applications with ClojureScript - vouch.io.
See how we use ClojureScript, React Native via Krell, and Storybook to manage complexity and improve workflow efficiency.

Read in full here:

This thread was posted by one of our members via one of our news source trackers.

1 Like

Corresponding tweet for this thread:

Share link for this tweet.

1 Like

Wow, amazing!
I don’t think it’ll take too much work to make ClojureScript work with NativeScript.

2 Likes

Creating a mobile digital key application involves various components, and writing a complete application here might be extensive. However, I can provide you with a simple example of a ClojureScript code snippet using a popular framework called Reagent. This example assumes a basic understanding of ClojureScript and assumes you have set up a ClojureScript project.

First, make sure you have Leiningen installed, which is a build tool for Clojure. Then, you can create a new ClojureScript project and include Reagent by following these steps:

Create a new project:

lein new figwheel my-mobile-key-app
cd my-mobile-key-app

Add Reagent as a dependency. Open project.clj and add the following to the dependencies:

:dependencies [[org.clojure/clojure "1.10.3"]
               [org.clojure/clojurescript "1.10.520"]
               [reagent "0.10.0"]]

Set up a basic Reagent component. Open src/cljs/my_mobile_key_app/core.cljs and replace its content with the following code:

(ns my-mobile-key-app.core
  (:require [reagent.core :as reagent]))

(defn digital-key-app []
  [:div
   [:h1 "Mobile Digital Key App"]
   [:p "Welcome to the digital key application!"]])

(defn ^:dev/after-load on-js-reload []
  (reagent/render [digital-key-app]
                  (.-app (.getElementById js/document "app"))))

(defn init! []
  (reagent/render [digital-key-app]
                  (.-app (.getElementById js/document "app"))))

Add an HTML file for rendering. Create an index.html file in the project root with the following content:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Mobile Digital Key App</title>
</head>
<body>
  <div id="app"></div>
  <script src="js/compiled/my_mobile_key_app.js" type="text/javascript"></script>
  <script>my_mobile_key_app.core.init_BANG_();</script>
</body>
</html>

Start the Figwheel development server:

lein figwheel

This will compile your ClojureScript code and start a development server. Open your browser and navigate to http://localhost:3449, and you should see your basic mobile digital key app.