Fork me on GitHub
#clojurescript
<
2020-07-06
>
Baishakhi Saha15:07:35

Does anybody know how to write the following syntax in clojurescript window.location.href=""? So far I've tried (set! (. js/window location -href) "")

Baishakhi Saha15:07:43

The error that I am getting is *set! target must be a field or a symbol naming a var*

noisesmith15:07:26

(. js/window location -href) returns the data at that location

Baishakhi Saha16:07:47

@noisesmith thanks a lot for the reply. What I'm trying to do is set the onclick attribute to location.href='' within the input tag to make a button which goes to another url, only by using reagent. I have implemented the html form before this, but strangely enough I'm redirected to a different url ( in this case an authorization end point not exactly valid or matching to where it needs to go). I was simply trying to check what happens if I use an input of type button acting as the link instead, but the real issue is with the form with the misdirected action.. any help would be appreciated!

thheller16:07:23

@baishakhi almost correct, should be: (set! (.. js/window -location -href) ...)

Baishakhi Saha16:07:34

@thheller that worked. Thanks!

benny17:07:43

how do i mimic the behavior of <!! in cljs async?

lilactown17:07:02

you can’t turn an async process into a blocking one in JS, so you’ll need to put your code that takes from the channel inside a go form

benny17:07:29

i’m using re-frame so this is going to be tricky. i need to read from local storage before executing the event using a coeffect. i’ll maybe check over in re-frame 😕

lilactown17:07:11

what does local storage have to do with core async, tho?

benny17:07:59

i’m using react native and therefore using asyncstorage as an interface

lilactown17:07:22

yeah coeffects are fundamentally synchronous, so I don’t think you’ll be able to use cofx for this

lilactown17:07:12

I think you’ll have to get the value from the asyncstorage and then dispatch the event

benny17:07:33

not a bad idea