Fork me on GitHub
#re-frame
<
2019-02-25
>
scknkkrer09:02:00

Guys, do you know how to find Clojurescript React and React-Native template to buy ?

andrea.crotti13:03:01

I'm not sure what that would mean @U3JJH3URY

andrea.crotti13:03:52

Cljs and reframe are not like WordPress

scknkkrer13:03:39

There are tons of templates, production-ready template projects written in React and/or React Native, over the internet. Is there for Clojurescript ?

andrea.crotti13:03:27

There could be but I doubt

scknkkrer13:03:42

I couldn’t found anytying. Also, I always proud of my Google-ing. I want to ask before I consider there are not any of them.

andrea.crotti13:03:31

I doubt there could be any market for something like that

andrea.crotti13:03:42

Just look at example projects

andrea.crotti13:03:49

As a starting point

gabor.veres11:02:50

Hi re-framers! I'm working my way through the todomvc example ( https://github.com/Day8/re-frame/tree/master/examples/todomvc ), and could use some insights.. So, our goal should be to have all of application state in app-db, so that the view can be derived from that only source. Despite this, there are some properties that are defined as "component-local" ratoms, such as the editing flag at https://github.com/Day8/re-frame/blob/01c63cc4b30591510acf415479b8e6d0614d5c1b/examples/todomvc/src/todomvc/views.cljs#L29 . This way app-db is no longer a definitive app state store, is it? Or, should we not consider "editing" to be part of the application state? If so, how do you decide what is state (as in: part of app-db) and what isn't...?

PB15:02:14

Hey friends, I'm trying to initiate a save file dialogue using day8-re-frame.http-fx. I see that hte file is being downloaded in the network tab as I can see the preview. But I'm unsure of how to handle this

(rf/safe-reg-event-fx
 :download-something
 (fn [{:keys [db]} _]
   {:http-xhrio {:method :get
                 :uri "/test"
                 :on-success [:do-something]
                 :on-failure [:do-somethingelse]
                 :format (ajax/transit-request-format)
                 :response-format (ajax/transit-response-format)}}))

valtteri16:02:25

Hi @petr, I think your server should return the response with Content-Disposition header. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

PB16:02:48

Hmm that might be it

PB16:02:53

I'll give that a shot

PB16:02:06

Even with that header it still doesn't appear to work

HTTP/1.1 200 OK
Content-Type: image/png
Content-Disposition: attachment
X-Xss-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Content-Length: 51601
Server: http-kit
Date: Mon, 25 Feb 2019 16:22:32 GMT

valtteri16:02:02

One option is to use a js-library such as https://github.com/eligrey/FileSaver.js/ to handle the download. Though (AFAIK) Content-Disposition header is the preferred way when the file comes from the server.

valtteri16:02:52

Try providing also filename=“something.png” in the header

valtteri16:02:54

Content-Disposition: attachment; filename="something.png"

PB16:02:35

Oh I see what's happening

valtteri16:02:37

Ehhh, the problem is probably that you can’t trigger file download with AJAX-request.

PB16:02:18

So if I take a look inside of my on-failure handler. There is this:

"EEEEEEEEEEEEE" {:response nil, :last-method "GET", :original-text "����JFIF���\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\...

valtteri16:02:43

You could just href to the endpoint?

PB16:02:12

It looks like its getting the binary data, but I need to push that to a file for the user to enter the dialogue

PB16:02:24

I can use an href

valtteri16:02:31

That would probably be the best.

PB16:02:47

But I like this more as I can theoretically handle 400s - 500s

valtteri16:02:25

Though.. It’s possible also to get the blob from Ajax-request and hand it over to filesaver.js and let it do some magic to popup the dialog

PB16:02:00

This is exactly what I needed

PB16:02:08

Thank you so much

anish21:02:42

Hello everyone,How to dispatch events from figwheel REPL ? #newbie-question #help

anish21:02:11

when i dispatch above code from REPL? I get error "RuntimeException Invalid token: ::events/initialize-db"

sofra23:02:49

@anish.developer the double colon in ::events/initialize-db refers to an alias. If for example you were to require a namespace such as (require '[my-re-frame.events :as events]) the keyword ::events/initialize-db would then expand to a fully qualified keyword :my-re-frame.events/initialize-db. So it depends on how your reg-event-db is defined, if you have used something like :events/initialize-db (with a single colon) then it is already fully qualified and you can just use it as is with the single colon, if you defined it like ::initialized-db then it will take on the name of the current namespace and you with have to either refer to the the fully qualified key or alias the namespace using require.

anish23:02:26

@sofra i have defined db as follows

anish23:02:43

so if i have dispatched event like (re-frame/dispatch-sync [:my-re-frame.events/initialize-db]) which is equivalent to (re-frame/dispatch-sync [::events/initialize-db])

anish23:02:23

i get error "event handler registered for: :my-re-frame.events/initialize-db"

anish23:02:46

i think its because of "::"

anish23:02:03

now i am bit confused about namespaces