[ClojureScript] Re: (failed) Attempts to inject cljs repl into 3rd party webpage

2019-08-13 Thread John Newman
I made a thing for that here https://www.chrepl.app/

I haven't made it work with shadow-cljs yet, but that'd be an interesting 
option.

V/r

John

On Tuesday, August 13, 2019 at 12:40:36 AM UTC-4, Sigmund Tzeng wrote:
>
> Hi there,
>
> Here are my steps to inject cljs repl into 3rd party webpage:
>
> 1. inject the following line via "Custom JavaScript for websites"
>
>  (function(){var d=document;var s=d.createElement('script');s.src='
> https://localhost:8090/js/main.js';d.body.appendChild(s);})()
>
> 2. *.edn file:
>
> ;; shadow-cljs configuration
> {:source-paths
>  ["src/dev"
>   "src/main"
>   "src/test"]
>
>  :dependencies
>  [[reagent "0.8.1"] ;[etaoin "0.3.5"]
>  ]
>  :ssl {} ;for shadow-cljs server, defaults to 9630 port
>  :http {:port 9630
> :ssl-port 23456
> :host "localhost"} 
>  :dev-http {8090 {:root "public"
> :push-state/headers {"Access-Control-Allow-Origin" "*" }}
>   }
>  :builds
> {:frontend
>   {:target :browser
>:asset-path "https://localhost:8090/js;
>:modules {:main {:init-fn acme.frontend.app/init}}
>}}}
>
> 3. modify main.js with no-cors mode
>
>   fetch(uri, {mode: 'no-cors'})
>
> 4. However, the browser endpoint (shown below) is never called 
>
> wss://localhost:23456/ws/worker/frontend/.../browser
>
> 5. what am i missing here? the emacs skewer-mode seem to work just fine.
>   Was wondering if DOMContentLoaded ever get fired, even so I don't know 
> how to fix/patch it.
>
>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojurescript/97a78456-54a2-4c2b-8e9b-95004b7f801d%40googlegroups.com.


Re: [ClojureScript] Subscriptions tracking in Re-frame

2019-08-13 Thread Deuseks
I think you may have hit on what I need to run - the level 3 subscriptions. 
I am reading from a database (datascript in this case) on the device and I 
want to minimize the number of queries I am making because I expect the 
database to grow in size. I have no problem with it being re-run if it is 
data residing in app-db, but it is this db access that I want to keep to 
the minimum.

Thank you for this link - I think I will REREAD my re-frame subscriptions 
literature and understand that a little better... 

Cheers @basket!!!

On Monday, August 12, 2019 at 10:04:20 PM UTC-4, basket. wrote:
>
> What is the problem with the subscription being re-run? Does it have side 
> effects? The part that confuses me is the new atom you are constructing 
> from the subscription, why not use a level 3 subscription? (
> https://github.com/Day8/re-frame-10x/blob/master/docs/HyperlinkedInformation/UnchangedLayer2.md).
>  
> The traces section might be helpful, here is a screenshot of the traces 
> from an application I am working on:
> [image: image.png]
>
> 
>  
> Victor Gil
> about.me/gilvictor 
> 
>  
>
>
> On Mon, Aug 12, 2019 at 7:50 PM Deuseks > 
> wrote:
>
>> I have seen re-frame-10x indeed..and it is a fantastic tool. And maybe 
>> that is where the answer lies as @danielcompton said on another issue. 
>> However, I guess what I am trying to debug is how to tell definitively, 
>> which specific de-ref of my reaction triggered a particular subscription to 
>> be rerun. 
>>
>> If this information is not currently something immediately available, I 
>> did have other questions such as:
>>
>>- Does re-frame cache the results of a subscription run ? if so, where 
>> is the documentation or even informal information about that ? 
>>- can I identify which specific deref causes a rerun ?
>>
>> While I can see the effects of running subscriptions and events in 10x, I 
>> am trying to debug the specific areas in code that triggered their running
>>
>> DOes this help ? 
>>
>>
>>
>> On Monday, August 12, 2019 at 5:46:16 PM UTC-4, basket. wrote:
>>>
>>> Hi there, I am not sure I understand your scenario, but have you tried 
>>> https://github.com/Day8/re-frame-10x ?
>>>
>>> 
>>>  
>>> Victor Gil
>>> about.me/gilvictor 
>>> 
>>>  
>>>
>>>
>>> On Mon, Aug 12, 2019 at 3:12 PM Deuseks  wrote:
>>>
 Hi
 I am using re-frame with expo/react native and my components are deeply 
 nested .I create a pass into this nested structure a new atom I construct 
 FROM the atom of a subscription. I pass that in since reactions cannot be 
 edited and I want this structure to be edited. However, the nested 
 structure contains a component that displays a modal. Whenever I open the 
 modal and close the modal control, it forces a re-fetch of the 
 subscription 
 data.


 The questions:

1. 

Why would the subscription be called again if I did not pass into 
the nested structure the original reaction ?
2. 

Should I worry about this retrigger even if the data has not 
changed ? I see it pulling the same stuff but maybe it is just passing 
 back 
results that are cached ? Are they cached ?
3. 

Is there a way in re-frame to definitively identify which deref of 
the reaction/atom causes the subscription to be re-run ?

 thanks for any help on this.

 -- 
 Note that posts from new members are moderated - please be patient with 
 your first post.
 --- 
 You received this message because you are subscribed to the Google 
 Groups "ClojureScript" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojur...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/clojurescript/5c3a1a6b-3cb6-4a0c-a0a8-4712d4ed60a6%40googlegroups.com
  
 
 .

>>> -- 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "ClojureScript" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojur...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/clojurescript/67dcb6e5-dce0-4a67-92ec-d167f10d781e%40googlegroups.com
>>  
>> 

[ClojureScript] Re: (failed) Attempts to inject cljs repl into 3rd party webpage

2019-08-13 Thread Thomas Heller
You cannot really inject a shadow-cljs dev build into any arbitrary page. 
It is not designed for that and will potentially conflict with the page 
itself in bad ways.

You can set :devtools {:devtools-url "https://your.host:23456"} to 
overwrite where the socket is trying to connect to. The Browser console 
will tell if you that connect fails.

DOMContentLoaded is not used by the CLJS build, not sure why you are asking 
about it. If you are trying to register an event handler for it you are 
likely just registering it too late when it has already fired.

On Tuesday, August 13, 2019 at 6:40:36 AM UTC+2, Sigmund Tzeng wrote:
>
> Hi there,
>
> Here are my steps to inject cljs repl into 3rd party webpage:
>
> 1. inject the following line via "Custom JavaScript for websites"
>
>  (function(){var d=document;var s=d.createElement('script');s.src='
> https://localhost:8090/js/main.js';d.body.appendChild(s);})()
>
> 2. *.edn file:
>
> ;; shadow-cljs configuration
> {:source-paths
>  ["src/dev"
>   "src/main"
>   "src/test"]
>
>  :dependencies
>  [[reagent "0.8.1"] ;[etaoin "0.3.5"]
>  ]
>  :ssl {} ;for shadow-cljs server, defaults to 9630 port
>  :http {:port 9630
> :ssl-port 23456
> :host "localhost"} 
>  :dev-http {8090 {:root "public"
> :push-state/headers {"Access-Control-Allow-Origin" "*" }}
>   }
>  :builds
> {:frontend
>   {:target :browser
>:asset-path "https://localhost:8090/js;
>:modules {:main {:init-fn acme.frontend.app/init}}
>}}}
>
> 3. modify main.js with no-cors mode
>
>   fetch(uri, {mode: 'no-cors'})
>
> 4. However, the browser endpoint (shown below) is never called 
>
> wss://localhost:23456/ws/worker/frontend/.../browser
>
> 5. what am i missing here? the emacs skewer-mode seem to work just fine.
>   Was wondering if DOMContentLoaded ever get fired, even so I don't know 
> how to fix/patch it.
>
>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojurescript/d1c90213-c433-42bf-a8e1-3bf5500295f4%40googlegroups.com.