Let's whine about react/redux



  • You know how MVC apps operate with 3-4 clear concepts (Model, View, Controller, maybe ViewModel and Router)?

    Well my react native / redux app operates with the following concepts:

    • actions
    • action creators
    • store
    • reducers
    • components
    • containers
    • sagas
    • selectors
    • services
    • router / scenes

    For example, to create a login screen, I needed to:

    • create a new scene
    • create a container for that scene
    • create components to fill in the container
    • connect the input properties from store to container
    • create new actions
    • create new action creators for these actions
    • connect events from container to action creators
    • create reducers to respond to synchronous actions
    • create new selectors, to extract derived data from the store
    • create sagas, to execute asynchronous requests and trigger additional actions

    Note that only component-s here are what you'd consider "actual" program that you care about, like the DOM/widgets and event handlers. Everything else is there just to fill in the maze of cruft in between your presentation layer and backend (Oh, did I forget to mention you need to code that too? This was only the frontend app).

    Remember when you could just add an <input> field, do a jQuery one-liner and you were done?

    Me neither.



  • @cartman82 Remember when you could just add an <input> field, do a jQuery one-liner and you were done?

    Or a simple one-line PHP POST check (that didn't work as intended and you had to regex it?) Cos yeah, I do remember that. We uh...kind of sometimes still do that. Because PHP.

    It's shit like this that makes me glad not to be a front-end developer. Even though I'm a PHP developer - which, if we were in the army, would make me the private nobody likes that always has to clean the toilets and gets letters home from Mummy about how hard things must be in the army and how she'll always love me even though I was starved of oxygen at birth



  • @thegoryone said in Let's whine about react/redux:

    Or a simple one-line PHP POST check (that didn't work as intended and you had to regex it?) Cos yeah, I do remember that. We uh...kind of sometimes still do that. Because PHP.

    Oh yeah. There was that too.



  • @cartman82 Plus most PHP frameworks are reasonably simple - Laravel and CodeIgniter are pretty straightforward to be fair to them without dragging out common functionality and making it harder to use (except for Laravel's Eloquent ORM, fuck Eloquent in the majority of cases)



  • You can always use Symfony - it's a beast of a framework, but simple stuff can be done in pretty simple ways. For example, adding whole user management (with all the controllers, db, views, etc.) requires one plugin and you're done.



  • @NeighborhoodButcher that's a backend framework. React/redux is a SPA setup.



  • @cartman82 said in Let's whine about react/redux:

    @NeighborhoodButcher that's a backend framework. React/redux is a SPA setup.

    Then you're doomed.


  • sockdevs

    @cartman82 said in Let's whine about react/redux:

    React/redux is a SPA

    0_1472233192992_upload-1ab088b3-9c5a-47aa-bc1e-2c1a385e18bf



  • Have they considered renaming it to 'Redact' (in the sense of an imperative or request)?



  • @NeighborhoodButcher said in Let's whine about react/redux:

    use Symfony

    Aka "let's put spring in PHP"



  • @cartman82 said in Let's whine about react/redux:

    Remember when you could just add an <input> field, do a jQuery one-liner and you were done?

    Browser vendors have been adding a lot of features from jQuery into the DOM, so you don't even need jQuery to do stuff in one line anymore.

    Plus, a lot of stuff that used to be jQuery plugins are now handled by things like <input type="date">.

    But sure, go ahead and reimplement the entire browser in JavaScript. That's probably the safest bet.


  • Winner of the 2016 Presidential Election

    @ben_lubar said in Let's whine about react/redux:

    But sure, go ahead and reimplement the entire browser in JavaScript.

    cough jsdom cough

    The code uses ES6 features, but maybe if you transpile it, it would run in a browser...


  • area_can

    @thegoryone said in Let's whine about react/redux:

    It's shit like this that makes me glad not to be a front-end developer.

    QFT



  • @cartman82 said in Let's whine about react/redux:

    sagas

    @cartman82 said in Let's whine about react/redux:

    Remember when you could just add an <input> field, do a jQuery one-liner and you were done?
    Me neither.

    Me neither.
    What is that j in jQuery?

    You webdevs have :poop: ed all over the language with that j, search any word and someone has written a new j framework to hide how shitty j itself is.



  • @dse said in Let's whine about react/redux:

    What is that j in jQuery?

    The imaginary root (as used in electrical engineering)? :upside_down:



  • @cartman82 said in Let's whine about react/redux:

    sagas

    Ok, I lost it there. That's a really good joke! The irony of using ever more grandiose words to describe mundane programming actions ... It's the work of a fine comedian. What will they think of when they need to combine sagas, or have some weird abstraction over sagas where all powerful objects send messages? A mythology?

    Lemme guess: it all started out as a simple, sane idea, which was then shoehorned into every possible library and function?



  • @Hanzo said in Let's whine about react/redux:

    Lemme guess: it all started out as a simple, sane idea, which was then shoehorned into every possible library and function?

    They used to have just the reducers. A pyramid of pure functions crystalizing immutable structures into the single application state. It was a real functional programming system. A pure system. The perfect system.

    Then someone realised: "Hey, what about when we want to get some actual data into our perfect system. You know, like through... ajax requests?"

    Thus, sagas were born.



  • @cartman82 said in Let's whine about react/redux:

    You know how MVC apps operate with 3-4 clear concepts (Model, View, Controller, maybe ViewModel and Router)?

    Well my react native / redux app operates with the following concepts:

    • actions
    • action creators
    • store
    • reducers
    • components
    • containers
    • sagas
    • selectors
    • services
    • router / scenes

    For example, to create a login screen, I needed to:

    • create a new scene
    • create a container for that scene
    • create components to fill in the container
    • connect the input properties from store to container
    • create new actions
    • create new action creators for these actions
    • connect events from container to action creators
    • create reducers to respond to synchronous actions
    • create new selectors, to extract derived data from the store
    • create sagas, to execute asynchronous requests and trigger additional actions

    Note that only component-s here are what you'd consider "actual" program that you care about, like the DOM/widgets and event handlers. Everything else is there just to fill in the maze of cruft in between your presentation layer and backend (Oh, did I forget to mention you need to code that too? This was only the frontend app).

    Remember when you could just add an <input> field, do a jQuery one-liner and you were done?

    Me neither.



  • @ben_lubar said in Let's whine about react/redux:

    But sure, go ahead and reimplement the entire browser in JavaScript. That's probably the safest bet

    When it comes to creating software platforms, there are basically two approaches:

    • Include every function a developer might possibly need
    • Include a small, but fast, set of instructions providing just the bare minimum, so that someone can create a proper library on top of it.

    Most platforms start with the first one, but as time progresses people realize the existing functions are not flexible enough to do what they want. So they end up reimplementing most of the platform on top of a small subset. It's inevitable.


  • area_can

    @ben_lubar said in Let's whine about react/redux:

    But sure, go ahead and reimplement the entire browser in JavaScript. That's probably the safest bet.

    TBH the way I see the web going in the future is everyone re-implementing stuff in the browser, either without HTML/CSS (e.g. canvas) or some other technology as people get fed up with dealing with designing applications for the web. so the web browser just becomes a display method for whatever graphical toolkit the site uses.

    /shrug


  • Winner of the 2016 Presidential Election

    @cark said in Let's whine about react/redux:

    The code uses ES6 features, but maybe if you transpile it, it would run in a browser...

    Most browsers support ES6 now.



  • @cartman82 said in Let's whine about react/redux:

    Then someone realised: "Hey, what about when we want to get some actual data into our perfect system. You know, like through... ajax requests?"
    Thus, sagas were born.

    You mean: Someone realised: with all this power, can we really control ourselves, or are we going to fuck over the mortals in subtle, and sometimes not-so-subtle, ways?

    And lo, He gave the weapon of Side Effects to Pandora, who hid it in her box, where He knew the mortals would one day discover it and use it to their doom. And thus began the saga of Cartman.

    Sing me, oh Muse, of that man skilled in all ways of programming, the hacker, harried for years on end.



  • @Hanzo Agile programming has "epics" and everyone seems to love it.



  • @Hanzo said in Let's whine about react/redux:

    Lemme guess: it all started out as a simple, sane idea

    Well ... it came from Cornell, and was originally a term used in CQRS (via, via) ... so I don't know that you can say that with any certainty :wink:


    In all seriousness, it's not a bad idea. But if you don't need it, just use Promises and a simple promise middleware. It won't be as easy to test, but it is still eminently testable.



  • @svieira said in Let's whine about react/redux:

    In all seriousness, it's not a bad idea. But if you don't need it, just use Promises and a simple promise middleware. It won't be as easy to test, but it is still eminently testable.

    Indeed, that's what I'm doing - a middleware talks to the database and then plonks the data into redux/react via actions.



  • @anonymous234 said in Let's whine about react/redux:

    @Hanzo Agile programming has "epics" and everyone seems to love it.

    They're collections of connected (user) stories. Seems to make some sense - perhaps "anthologies" would be a better word?

    If you want stupid names, try metaheuristics. It's like they get +50% to their grants to come up with stupid names - ant colony optimization (having nothing to do with ants), annealing (having nothing to do with metal), tabu search (having nothing to do with charades)...



  • @Rhywden said in Let's whine about react/redux:

    Indeed, that's what I'm doing - a middleware talks to the database and then plonks the data into redux/react via actions.

    That's called "thunk", and is soooo last month, granpa.


  • Winner of the 2016 Presidential Election

    @Hanzo said in Let's whine about react/redux:

    Pandora, who hid it in her box, where He knew the mortals would one day discover it and use it

    :giggity:



  • @cartman82 you know why the bleeding edge is called "bleeding" ?



  • @cartman82

    NASA dashboards!!!

    (stock webpack console output)'s cool, but its mostly noisy and scrolly and not super helpful. This plugin changes that. Now when you run your dev server, you basically work at NASA:



  • This isn't the chemistry thread I expected it to be.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.