News for hackers. Stuff that matters.

flwralex

Re:Name It, and They Will Come on Monday March 25, 2019 @07:26PM (#19487760)
"By now, you’re convinced: This idea deserves to be heard."

This week my first public project got 7 git stars. The feeling is fantastic. I don't have homepage or story, but I have a nice diagram :)

The question for me is why I'm releasing this, to feed the ego monster or because I really beleive it's worth it? I hope it's not the first, but not sure, tbh.

Re:Architecting UIs for Change on Saturday March 23, 2019 @10:22AM (#19470540)
Thank you so much for checking it out. I'm so happy that diagram makes sense to you.

One of my favorite talks is from Robert Martin, the first link on the bottom of the about.md - when he explains the history of MVC, I realised that the original idea for MVC is exactly what Redux is. But in the years people changed the meaning of MVC and that's why now it seems different. For me, Redux is 1:1 as M from original MVC docs from the 70s.

I'm also torn on using "standards" vs my own implementation. I feel kinda like an outcast, using my own "framework".

Side joke: With hooks and functional components, the React community is moving in our direction. I cannot wait for the next logical conclusion - Lets move the hooks out of the components :)

I would like to see some of your code, if you like to share it, please send me an email: alex.tzvetanov at gmail com

Thank you again for spending time on my code and thanks for the feedback!

Re:Ask HN: Go-to web stack today? on Sunday January 06, 2019 @02:49AM (#18837168)
Really sorry to call you noob. You may have more experience dealing with Redux codebases from me, but in any case I was arrogant and I'm sorry.
Re:Ask HN: Go-to web stack today? on Saturday January 05, 2019 @12:42PM (#18832973)
Hi, if you mean how to get rid of switch statements, you can check my comment bellow - about "action-reducer".

I've seen https://github.com/erikras/ducks-modular-redux and it's close to what I do.

Also you can check - https://github.com/reduxjs/redux/issues/1167#issuecomment-38...

Re:Ask HN: Go-to web stack today? on Saturday January 05, 2019 @10:09AM (#18831977)
Example of "action-reducer" - combine action and reducer as one IIFE. Use object-path-immutable to update the state.

In any action.ts file you can have as many actions as you wish. Every action has type, dispatch and reduce methods:

  export namespace indexSaveSsl {
    export const type = 'INDEX_SAVE_SSL';
    export const dispatch = (store, response) => {
      store.dispatch({
        type,
        data: response.data
      });
    };
    export const reduce = (state, action) => immutable(state)
      .set('Reports.data.ssl', {})
      .set('Reports.data.ssl.result', action.data)
      .set('Tools.options.ssl.test_running', false)
      .value();
  }
This is typescript namespace, but compiles to IIFE.

This is how actions is combined:

  export const actions = (() => {
    // import main actions via webpack
    const actionsMain = require.context('app/', true, /actions\.ts$/);
    const mainFinal = actionsMain.keys().reduce((prev, key) => Object.assign(prev, actionsMain(key)), {});
    return mainFinal;
  })();
You can call it:

  actions.indexSaveSsl.dispatch(store, resultSsl);
And here how to generate reducers from actions:

  const reducer = (state = {}, action) => {
    // main reducer
    const result = Object.keys(actions)
      .filter((item) => actions[item].type === action.type)
      .map((item) => actions[item].reduce(state, action));
    return result[0] || state;
  };

  createStore(reducer, hydrate, extension);
No switch statements and reducers.
Re:Ask HN: Go-to web stack today? on Saturday January 05, 2019 @08:46AM (#18831594)
When Redux stops to buffles you, might be the good time to give advice about it. You might implement it 20 times, but if you don't understand it, every time will be pain. Redux can be life saver even for single developer, so team size dosen't matter.

Would be funny to say, I've tried 4 times to tie my shoes, but didn't go well, so you shuldn't tie your shoes...

So much hate, whithout any reason is what buffles me.

Re:Ask HN: Go-to web stack today? on Saturday January 05, 2019 @06:32AM (#18831150)
I would be happy to show you how to use redux, without switch statements and even without reducers. It's not that hard, and if you don't like it, just use other state management libs. But don't call it poor design - it has 2 methods.