Fork me on GitHub

Hi folks! has anyone here have experience with code reloading in a Cordova + cljs using shadow-cljs please? I would really be interested in knowing how to make it work right on the device!thanks in adv


whats the issue? I'd assume a regular :browser build would do the trick?


at the moment this is what we are doing : we develop in the browser with all the advantages of having it refresh automatically etc. but we were wondering whether there were some way of having the app deployed right on a device (Android/iOS or emulators) and still have the code reload right on the device (without redeploying using cordova CLI again) when we change stuff


I just did a quick test and after some manual tuning it works as expected


@U0DTAJS3Y there is - you need to have your app container page redirect to your shadow watch-build, and you need to copy these files into the directory shadow is serving from

👍 4



maybe this helps


does that do the redirect for hot-reloading on-device @U05224H0W ?


I only tested windows though ... so "device" is my windows machine


no clue about other platforms


requires too much setup I don't have time for


sure - i've done it for both ios and android, simulator and hardware - the same approach works for all combos


hey guys @U05224H0W @U0524B4UW thanks a lot for your help ...I will give it a shot on my side


here are our shadow build config overrides for ios and android watch builds @U0DTAJS3Y.... we're using gulp for our build-system, so we've got EDN for the overrides jammed into js literals, but you should get the idea:

💯 4
👍 4

wow awesome 👌 again thanks


I just realized I should probably announce that as part of building the byte field diagram generator I’m creating to port a big LaTeX document to Asciidoctor/Antora, I have ported Analemma ( to .cljc so it works in ClojureScript as well as Clojure, and (with David Liebke’s permission) posted a canonical release to Clojars.


That may be worth posting at #announcements


Ah, I wasn’t even aware of that channel, I see #admin-announcements but hadn’t yet joined the other one, thanks!


Any equivalent of extends? in cljs? Or at least better than:

#(satisfies? protocol (new %))
I’ve been digging around and I can’t seem to find anything, other than perhaps sticking the above in a macro.


what are you trying to do?


AFAIK in general, you can’t know that a type or record implements a protocol without constructing it, because under the hood a type / record is just a constructor function which returns an object


this is different than the JVM, where a class is an actual concrete concept in the runtime


I think it’s usually best practice to pass around instances of types/records rather than the type/record itself


I’ve got something that’s really similar to an ECS style system, so I’m using protocols to group together related functionality. I don’t want a situation where adding a new type of record (which is just a map after all) requires me to change a bunch of calls sites when what I’m interested in is stuff like, now call all the physics stuff, now call all the render stuff…


Let me know if I’ve been unclear =)…


protocols should solve that, yes


it’s unclear to me why you would pass the Record constructor in rather than an instance of the record into a call site


> a new type of record (which is just a map after all) a “type of record” is not a map though, it’s a function. an instance of a record is the one that implements all of the same protocols as a map


(defprotocol IRenderable
  (-render [this]))

(defrecord Player []
  (-render [this]

(defn render [renderable]
  {:pre [(satisfies? IRenderable renderable)]}
  (-render renderable))

(render (->Player))


So I have :entities which is a collection of different records that all implement the IEntity protocol, however certain functions, like ai, will only want to loop through stuff with IMonster. Now finding all the records which implement a protocol by looping through the entities list is expensive, so I have a :entities-with-component, which is a map of types of entities to a collection of entity id’s of that type, then I can quickly get by the type I’m interested in and then do a get to turn the entity-ids into entities. Now I’m going a step beyond that, by using extends I can say give me all the entities that implement this protocol. But I can’t do that in cljs without doing #(satisfies? protocol (new %)).


I mean if I could take a record and get the protocols it implements that might work too? But it feels a little bit more messy…


"Now finding all the records which implement a protocol by looping through the entities list is expensive" is it? if that's really true then I'd suggest creating a second map of protocol->entities (there's no real reason to use id's with persistent data structures). I'm ever so slightly skeptical of this performance issue though 🙂


it sounds like you’re trying to create a mapping on top of the component->entity mapping, behavior->component->entity . but why not behavior->entity?


oh it's a game and your entities probably have some sort of state associated with them, that explains the id thing


you’re losing out on all the goodness of protocols by trying to map behavior to concrete types


@lilactown As in for every behaviour create a reference to the entity? Not thought it about it. Will give it a try.


Are there any safe ways to redef functions when using core.async go blocks in ClojureScript? I ran into the same issue found here which doesn’t provide any alternatives. I ended up making a test fixture that resets the values after each test but wondering how other people are doing this.


I do it with fixtures as well


depending on what level of abstraction you are operating at, you can create a macro or function that re-binds the values at each async barrier.

(let [dynamic-var *dynamic-var*]
    (binding [*dynamic-var* dynamic-var]
I’ve used this to similar effect when creating a data fetching framework that worked with server-side rendering, isolating the cache between requests


this doesn’t work as a general way to redef/rebind things you don’t control that use core.async


@lilactown right, I can introduce some code specific things, I was considering just making a version of the function that got passed all deps so I could just provide them.


the fixtures method definitely works, gives me some confidence if you’re doing the same @dnolen 😄