funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
niwinz 2016-01-15T06:10:05.000280Z

@kenny: It has worked any solution?

1👀
kenny 2016-01-15T19:14:03.000281Z

@niwinz: Right. The problem with those solutions is that they both put the static assets under route. I do not want the assets to be under a route. I want the static assets to be located at / or the root.

niwinz 2016-01-15T19:33:54.000282Z

oh

niwinz 2016-01-15T19:34:05.000283Z

I missed that part, sorry.

niwinz 2016-01-15T19:34:42.000284Z

The last solution should work for you I think.

niwinz 2016-01-15T19:35:21.000285Z

In any case just now I'm doing some work in cartacumba so I'm going to create a test case for that

niwinz 2016-01-15T19:55:01.000287Z

this can be done with the catacumba 0.10.x

niwinz 2016-01-15T19:55:07.000288Z

and it works as expected

kenny 2016-01-15T19:55:25.000289Z

Awesome!

1🎉
niwinz 2016-01-15T19:56:06.000290Z

The catacumba 0.11.x will expose a simple way to serve yourself files in a efficient way 😉

kenny 2016-01-15T19:56:14.000291Z

Even better :simple_smile:

kenny 2016-01-15T19:56:39.000292Z

On a separate note.. Is there a way to add a on-closed handler to a postal socket?

niwinz 2016-01-15T19:57:19.000293Z

hmm postal socket is just a normal websocket with simple encode/decode middleware, and websockets expose a ctrl channel that can be listen for client close messages

niwinz 2016-01-15T19:58:19.000294Z

in the same way as you get in and out channel, you can obtain the ctrl

kenny 2016-01-15T20:01:50.000295Z

So when ctrl closes the websocket has been closed?

niwinz 2016-01-15T20:03:19.000296Z

ctrl will populated with [:close] or [:error] and inmediatelly closed

niwinz 2016-01-15T20:04:38.000297Z

In any case, does not tie your code to the values in ctrl channel

niwinz 2016-01-15T20:04:50.000298Z

are subject to change (I don't like the current value)

niwinz 2016-01-15T20:05:00.000299Z

consider that if a message received in ctrl channel

niwinz 2016-01-15T20:05:10.000300Z

the user has closed the connection

kenny 2016-01-15T20:05:37.000301Z

Got it

kenny 2016-01-15T20:06:20.000302Z

Maybe in the future on-error and on-close functions can be passed to the postal socket function ?

niwinz 2016-01-15T20:07:16.000303Z

hmm nice idea

niwinz 2016-01-15T20:07:30.000304Z

(defn subscribe-to-events
  {:handler-type :catacumba/websocket}
  [{:keys [in out ctrl]}]
  (let [ch (ws/subscribe)]
    (go-loop []
      (let [[v p] (a/alts! [ctrl ch in])]
        (cond
          ;; RECEIVING MESSAGES FROM FRONT
          (= p in)
          (do ws/dispatch v)

          ;; NORMALLY CAUSE FRONT HAS CLOSED
          (= p ctrl)
          (do
            (println "closed")
            (a/close! ch))

          ;; SENDING MESSAGES TO SUBSCRIBERS
          (= p ch)
          (do
            (>! out v)
            (recur)))))))

niwinz 2016-01-15T20:07:38.000305Z

this is a simple example

kenny 2016-01-15T20:09:13.000306Z

What is ws/subscribe?

niwinz 2016-01-15T20:10:03.000307Z

this code is out of context

niwinz 2016-01-15T20:10:37.000308Z

the subscribe is part of the logic from where I have extracted the code...

kenny 2016-01-15T20:11:29.000309Z

Oh I see. It's just a channel you use to send messages from other places.

niwinz 2016-01-15T20:11:35.000310Z

yes 😛

niwinz 2016-01-15T20:11:51.000311Z

is just a "event bus" or "pubsub"

niwinz 2016-01-15T20:12:39.000315Z

Here an other example

kenny 2016-01-15T20:13:34.000316Z

Cool thanks!

niwinz 2016-01-15T20:15:03.000317Z

As far as I can see, you are using postal, I really appreciate some feedback/comments/opinons about it 😛

kenny 2016-01-15T20:16:12.000318Z

I really like the higher level of abstraction so I don't need to worry about the nitty gritty parts of client-server communication

kenny 2016-01-15T20:16:59.000319Z

I also really like the stream model. Have you considered writing a version of beicon for clj so that you can use streams on both sides of the postal api?

niwinz 2016-01-15T20:17:48.000320Z

\o/

niwinz 2016-01-15T20:18:40.000321Z

You are not the first one that ask for clj version of beicon

niwinz 2016-01-15T20:19:09.000322Z

The problem with streams is its backpressure support

niwinz 2016-01-15T20:20:20.000323Z

In client side, streams are used because backpressure in js is not very important (and ws does not has clear access for proper handling it)

niwinz 2016-01-15T20:20:34.000324Z

but in server side is very important

niwinz 2016-01-15T20:21:09.000325Z

but is more "complicated" in term of syntax handle properly backpressure with streams in backend

niwinz 2016-01-15T20:21:27.000327Z

and channels handles that much better

niwinz 2016-01-15T20:21:40.000328Z

this is the main reason because core.async is used in the backend

niwinz 2016-01-15T20:22:18.000329Z

But I'll spend some time in research in the posibility to build beicon for clj

niwinz 2016-01-15T20:22:33.000330Z

I also prefer the stream approach over core.async

kenny 2016-01-15T20:23:46.000331Z

Right. Yeah I also like the stream approach. I end up with cleaner code.

niwinz 2016-01-15T20:27:02.000332Z

At this moment the core.async method is more "production" ready because it handles backpresure apropriatelly and allows not send/receive messages that client/server can't process.

kenny 2016-01-15T20:28:53.000333Z

Yeah. I'll keep using core.async for now :simple_smile:

kenny 2016-01-15T20:34:00.000334Z

Does closing ctrl on the server also close the websocket connection?

kenny 2016-01-15T20:35:00.000335Z

It looks like it does. Just verifying that everything actually got closed..

niwinz 2016-01-15T20:35:58.000336Z

the recommended is closing the out

niwinz 2016-01-15T20:37:05.000337Z

closing the out channel is way to do it.

kenny 2016-01-15T20:37:31.000338Z

Okay