cljsrn

https://github.com/drapanjanas/re-natal | https://github.com/drapanjanas/re-natal/wiki/FAQ | https://github.com/condense/mercury-app/wiki | https://github.com/seantempesta/expo-cljs-template/ https://www.npmjs.com/package/create-expo-cljs-app
admarrs 2020-04-30T11:28:38.404400Z

I think I'm seeing intermittent behaviour with Krell and asset js/require. With an initially working example, a simple code change and recompile results in an empty Krell_assets.js

admarrs 2020-04-30T11:29:28.404800Z

Deps.edn:

admarrs 2020-04-30T11:29:56.405100Z

{:deps {io.vouch/krell {:git/url "<https://github.com/vouch-opensource/krell.git>"
                        :sha "9c88f29fcc25780238914ad52f266c349c2bd787"}
        io.vouch/reagent-react-native {:git/url "<https://github.com/vouch-opensource/reagent-react-native.git>"
                                       :sha "54bf52788ab051920ed7641f386177374419e847"}
        reagent {:mvn/version "1.0.0-alpha1"
                 :exclusions [cljsjs/react cljsjs/react-dom]}}}

admarrs 2020-04-30T11:30:17.405300Z

core.cljs:

admarrs 2020-04-30T11:30:26.405500Z

(ns krell-project.core
  (:require [react :as react]
            [reagent.core :as r]
            [reagent.react-native :as rn]
            [react-native-reanimated :as re-module]
            [react-native-gesture-handler :as rg]))

(def re (.-default re-module))

(def animated-view
  (r/adapt-react-class (.-View re)))


(defn ^:export -main [&amp; args]
  (r/as-element
    [rn/view {:style {:flex 1}}
      [rn/view {:style {:flex 1 :align-items "center" :justify-content "center"}}
        [animated-view 
          [rn/image {:source (js/require "../../resources/img/card1.png")
                    :style {:width 300 :height 200 :borderRadius 18}}]
        ]
        [rn/text "Hello"]
      ]
    ]))

admarrs 2020-04-30T11:30:46.405800Z

Krell_assets.js:

admarrs 2020-04-30T11:30:53.406Z

module.exports = {
  assets: {
  }
};

admarrs 2020-04-30T11:34:01.407200Z

When I delete target/ and .cpcache/ and clj -m krell.main -co build.edn -c -r all works as expected - Krell_assets.js:

admarrs 2020-04-30T11:34:16.407400Z

module.exports = {
  assets: {
    "../resources/img/card1.png": require('../resources/img/card1.png')  }
};

dnolen 2020-04-30T12:30:03.407800Z

@admarrs yes that's a known issue, working on it

admarrs 2020-04-30T14:57:13.408100Z

@dnolen ok, thanks

dnolen 2020-04-30T17:21:13.409Z

Krell master has a fix for asset/requires, some of you may have noticed breakage after a recompile - the big problem should be fixed - there may be edge case still - minimal repros would help

dnolen 2020-04-30T17:22:15.410200Z

If you're going to try master, remove .cpcache, remove your :output-dir, and make sure you're not specifying a ClojureScript version - Krell is back on ClojureScript master for now

dnolen 2020-04-30T17:23:24.411200Z

I'm trying to move from re-natal to Krell on a medium-ish application so it's getting a real-world spin right now

👍 2
admarrs 2020-04-30T17:26:44.413100Z

@dnolen that's great. On your medium-is application how are you managing state? Playing with the simple reagent example Ratom doesn't seem to trigger a re-render, I guess because of the wrapping r/as-element.

dnolen 2020-04-30T17:27:26.413400Z

@admarrs in the app I'm porting we're using re-frame

dnolen 2020-04-30T17:27:46.413900Z

@admarrs don't follow the tutorial for tips on how to use Reagent, I'm not a Reagent expert - if that's wrong I can fix it

dnolen 2020-04-30T19:04:42.414800Z

@admarrs I looked into this a bit, it's because Ratom is a bit magical

dnolen 2020-04-30T19:04:50.415100Z

it needs to be executed in a context that Reagent controls

dnolen 2020-04-30T19:05:13.415700Z

so if you add some indirection (r/as-element [my-fn])

dnolen 2020-04-30T19:05:27.416100Z

and only put Ratom stuff "beneath" my-fn it will work

dnolen 2020-04-30T19:10:26.416500Z

@admarrs I've updated the tutorial - it's a simple thing to stumble over

dnolen 2020-04-30T19:10:48.417Z

in fact ran into in the app I was porting and couldn't figure it out w/o reading Reagent source

dnolen 2020-04-30T19:14:21.417200Z

adding some clarifying text as well