Skip to content

Instantly share code, notes, and snippets.

View StankovicMarko's full-sized avatar

Marko Stanković StankovicMarko

View GitHub Profile
@StankovicMarko
StankovicMarko / test.cljs
Created July 12, 2021 16:06
implementation of react-native-gesture-handler in clojurescript and react native (cljsrn) https://snack.expo.io/@adamgrzybowski/react-native-gesture-handler-demo
;; It's very important to update main activity as per https://docs.swmansion.com/react-native-gesture-handler/docs/#updating-mainactivityjava
;; otherwise this example won't work
(ns test.app
(:require ["react-native-gesture-handler" :as gesture]
["react-native-reanimated" :as re-animated]
[shadow.react-native :refer (render-root)]
["react-native" :as rn]
[reagent.core :as r]
[goog.object :as goog-obj]))
(defn real-draggable-view []
(let [pan (new rn/Animated.ValueXY #js {:x 0
:y 0})
pan-responder (rn/PanResponder.create #js {:onStartShouldSetPanResponder (fn [arg] true)
:onPanResponderGrant (fn [e state]
(.setOffset ^js pan #js {:x (goog-obj/getValueByKeys pan #js ["x" "_value"])
:y (goog-obj/getValueByKeys pan #js ["y" "_value"])}))
:onPanResponderMove (fn [e state]
(.setValue ^js pan #js {:x (goog-obj/get state "dx")
:y (goog-obj/get state "dy")}))
@StankovicMarko
StankovicMarko / deps.edn
Created January 14, 2021 12:17 — forked from mikeananev/deps.edn
Clojure compress / decompress data examples
{:deps {org.clojure/clojure {:mvn/version "1.10.0"}
com.taoensso/nippy {:mvn/version "2.14.0"}
org.apache.commons/commons-compress {:mvn/version "1.18"}}}
@StankovicMarko
StankovicMarko / core.clj
Created September 14, 2019 07:34 — forked from piecyk/core.clj
clojurescript google maps API
(declare *map*)
(def user-events (atom []))
(defn handler-events [res]
;; clear markers from the map
(doseq [e @user-events]
(.setMap (:marker e) nil))
(let [m (map #(assoc % :marker (event-marker %)) res)]
(reset! user-events m)))

React Navigation is a great component for building mobile applications. It is versatile and supports both dominant platforms beautifully. However, despite the 2 libraries that exist out there to support this component in the Clojure ecosystem, there is sadly very little documentation on what and how you can set up and use this component. I could not get them to work for me (my failing) so I decided to try and make it work without the existing libraries just to that I can understand what is going on. Below is a laying out of my experience. Let me know if you have corrections so that we mortals who are not that sharp can learn.

React Navigation requires an exact set of steps to make it successfully work

Step 1: Installation of React Navigation

Use yarn to add the library to the project

https://github.com/drapanjanas/re-natal#enabling-source-maps-when-debugging-in-chrome
fs.js:119
throw err;
^
Error: ENOENT: no such file or directory, open 'node_modules/metro/src/Server/index.js'
at Object.openSync (fs.js:448:3)
at Object.readFileSync (fs.js:348:35)
at readFile (/home/marko/.nvm/versions/node/v11.12.0/lib/node_modules/re-natal/re-natal.coffee:156:6)
console.error: "ERROR [taoensso.sente:1058] - WebSocket error: [object Object]"
error
index.android.delta?platform=android&dev=true&minify=false:62178:29
dispatchEvent
index.android.delta?platform=android&dev=true&minify=false:24523:31
<unknown>
index.android.delta?platform=android&dev=true&minify=false:25759:31
emit
index.android.delta?platform=android&dev=true&minify=false:2852:42
__callFunction
(ns project.websocket
(:require
[taoensso.sente :as sente]
[taoensso.encore :as encore]
[re-frame.core :as rf]))
(defn start-websocket [csrf-token]
(let [{:keys [chsk ch-recv send-fn state]}