Fork me on GitHub
#re-frame
<
2017-10-12
>
Bravi08:10:59

what is a better way to get data from the server on page load, than using component-did-mount lifecycle? I’m trying to avoid using lifecycles.. they make me cringe in re-frame environment

djtango09:10:33

@luvuiken @manuel thanks will take a look

sandbags09:10:18

@bravilogy perhaps I misunderstand but couldn't your dispatch your event after :initialize-db?

Bravi09:10:30

yeah that’s what I ended up doing

Bravi09:10:45

I found it in one of the examples

Bravi10:10:21

yeah I was looking around that page, but couldn’t find the on-load example and I was sure I could avoid using lifecycles

Bravi10:10:08

and then I noticed how the initialisation was working and added that bit to google and voila!

Bravi10:10:42

damn it’s so satisfying to write scalable code.. I know I’m still at baby steps, but adding a bit of functionality is literally adding a few additional tiny functions

Bravi10:10:10

makes me want to rewrite my portfolio website in Clojure, which is currently written in Laravel + React. Probably worth doing it purely for practice

lovuikeng10:10:59

I'm sure, @bravilogy working with only pure function and immutable data feel so much relief

lovuikeng10:10:34

and re-frame has been one great showcase of the power of clojure in that sense

Bravi10:10:56

yeah definitely. now I need to get my head around routing, server-side Clojure aaand I think I’ll be good to go 😄

lovuikeng10:10:50

been hoping to see a full-stack with re-frame, still looking..., otherwise, re-frame is simply best for frontend work

manutter5111:10:51

I was looking for full-stack re-frame too, but then I realized that the heart of re-frame is managing the DOM by maintaining a shadow version of it, so it doesn’t really make sense on the server (assuming you’re not rendering pages there).

manutter5111:10:54

I’ve been looking at the CQRS pattern in general, and Pedestal in particular, because I think that’s closer to what it is about re-frame that sounds so appealing server-side.

lovuikeng11:10:52

no @manutter51 I never meant to have a server-side re-frame, I was only hoping to see a great full-stack with re-frame as frontend

lovuikeng12:10:00

yes, CQRS is kind of natural fit although it's remained to see a case on production

lovuikeng12:10:53

on #duct , @rickmoynihan shared endpoint of lacinia-pedestal, which I find the subscription is like match in heaven with re-frame 🙂 http://lacinia-pedestal.readthedocs.io/en/latest/subscriptions.html , although I find websocket is overkill

rickmoynihan09:10:59

yeah kinda annoying that it uses websockets…. I think it would be better for my purposes if it used SSE’s

lovuikeng11:10:33

yes, SSE is much better since it's standard HTTP, although SSE connection isn't that stable, not for critical use case anyway. Looking forward to JSON Streaming for sure http://oboejs.com/

mikethompson13:10:18

@manutter51 I believe the heart of re-frame is the discipline it imposes around state management. A discipline which is both effective but surprisingly flexible. The flow of state from app-db to views is *a part* of that, as you propose.

mikethompson13:10:23

But just a part

manutter5113:10:39

Yeah, I was sloppy in how I phrased things, you said it better.

manutter5113:10:30

I was referring to re-frame existing on top of reagent, which sits on React, which is a DOM management system

manutter5113:10:07

So re-frame is a discipline that I wish I could use everywhere, and it’s currently being applied in this specific area.

mikethompson13:10:33

Hmm. I'd still say it a bit differently. The stack you refer to is about the 'V' (view) part of the traditional MVC. So, yes, re-frame incorporates that but there is more going on than that (covering the parts normally called M and C).

Bravi13:10:46

perhaps someone here knows how to use garden? not a single example shows how to attach styles to dom elements 😞

mikethompson13:10:41

@bravilogy You may have the wrong idea. Garden allows you to create CSS. You then attach that CSS to elements as normal. Via classes etc.

Bravi13:10:38

I thought it was something similar to what React is doing

Bravi13:10:42

damn.. that’s why 😄

manutter5113:10:31

@mikethompson That’s fair. I’m trying to say something like, “Re-frame doesn’t really apply to server-side/non-client code because __“. But of course, I’m assuming that’s a valid thing to say. I’d be interested to hear your thoughts on how re-frame would apply to server side stuff, or if it would.

mikethompson13:10:26

@manutter51 This question does come up a bit. I've captured my minimal opinion here: https://github.com/Day8/re-frame/blob/master/docs/FAQs/FullStackReframe.md Sorry, that's all I have

lovuikeng13:10:06

on server side it'd something like kafka live stream

manutter5113:10:37

Ok, that’s roughly what I was thinking (however badly I may have expressed it :D)

mikethompson13:10:31

I hope the links help. Bobby Calderwood's talk is quite useful.

manutter5113:10:55

I started looking at Kafka-based stuff, and IIRC the Kafka docs recommend running on machines with 32GB of RAM, which is a bit rich for my blood.

manutter5113:10:17

Yeah, I saw Bobby Calderwood give a version of that talk at Abstractions, it was excellent.

mikethompson13:10:30

Our current solution is to use CQRS without Event Sourcing. So we don't do the entire Kafka thing.

mikethompson13:10:51

We've also experimented with rethinkdb and its live-queries acting like subscriptions

manutter5113:10:02

I guess Kafka is really geared towards big distributed cloud-based stuff, so for lesser stuff you don’t need the full power Kafka provides.

mikethompson13:10:03

But then rethinkdb went out of business

manutter5113:10:13

could redis pub/sub work for something like that on a sub-Kafka scale?

mikethompson13:10:14

Sure. via websokets. Or firebase

mikethompson13:10:58

I'm so pissed off that rethinkdb fell over

mikethompson13:10:27

(commercially)

lovuikeng13:10:43

yet to see how confluent is riding on kafka

kah0ona14:10:20

is it possible to use the value of a subscribe in a event-db handler? does that make sense at all? I ask this because I have a subscribe handler that listens to the position of the mouse. Later, in an event, I need to get the latest value of this. Now technically i can cache this all in the app-db, but for more complex subscriptions (that depend on other subscriptions, ie. do sorting, filtering etc.) i sometimes want to listen to a subscribe value from within an event handler. Haven’t thought it through completely if this would mess things up 🙂 Any advice?

kah0ona14:10:25

I could of course just try it, but kinda wanna make sure i’m not committing unforgivable sins 😉

kah0ona14:10:28

I kinda feel that this is not going to work since the fn is run all the time, and would re-subscribe it basically.

kah0ona14:10:12

but come to think of it i would love to be able to get a value from a pretty complicated subscribe that does collision detection of divs (working on drag/drop stuff) I could listen to the value of the sub and re-insert it through a dispatch as an argument, of course, will do that for now.

kah0ona14:10:32

but it would make my view a bit more complicated

lovuikeng14:10:41

we are all sinners in clojure land becaused we are all uniformly parenthesesed

danielneal14:10:20

@kah0ona there is a library somehwere which provides an inject-sub cofx for use in handlers

danielneal14:10:26

it has the mike seal of approval too 😄

lovuikeng14:10:57

there is re-frame utils too? thanks @danieleneal

kah0ona15:10:28

@danieleneal just tried it, and it works like a charm! Very cool

danielneal15:10:41

yeah I was really pleased to discover that library - just two functions but both fill in the little gaps in reframe at the edge...

nolan33023:10:06

Hey everyone, I

nolan33023:10:15

've got a problem with a JS object in app-db not triggering a rerender. Is this a common problem? Or is it more likely that I'm misusing forms 1 and 2, and not that it's a nested value in a JS object thats being modified?

mikethompson23:10:03

@nolan330 putting js data into app-db probably won't work. You won't get proper = checks.

nolan33023:10:26

Ok, got it. Yeah after staring at it blankly for longer, its obvious why I was having an issue.

nolan33023:10:46

Incredible how effective that technique is. Thanks for the input! @mikethompson