I'm using the expo-cljs-template (lein new expo myapp +reagent
) to bootstrap my expo/react-native/reagent/clojurescript app.
Because my application needs geofencing, and in expo that needs a TaskManager
, I define a TaskManager
task like so:
(ns myapp.mod
(:require [oops.core :refer [ocall]])) ; javascript interop
(def taskmanager (js/require "expo-task-manager"))
; call outside of component as per react-native requirement
; to be done during initialization phase
(ocall taskmanager "defineTask" "task-name" (fn [data error] (prn "nowt")))
I've got this running very early in my app, before even images are required. But I consistently get the TaskManager.defineTask must be called during initialization phase!
error, running with figwheel dev-mode. If the top and base level of the clojurescript is not initialization phase, then when is? Is something run before my clojurescript? I've also tried calling it within the init function and within app-root as a reagent type 3 component.
Version information: expo "^34.0.3", react "16.8.3", react-native "34.0.0", expo-task-manager "~6.0.0", reagent "0.8.1"
The issue lies within the initialization mechanism used in re-natal/figwheel.
It first loads a simple bridge helper JS file that doesn't contain any of your own code. It just sets up the initial loading process. This code is loaded async and when done it will render your actual app code replacing the placeholder it first used.
I'm not aware of a way to actually run your code in a sync way as expo
expects with re-natal/figwheel.
You can try shadow-cljs which does not have this async issue.