Skip to content

Instantly share code, notes, and snippets.

View jaszczw's full-sized avatar

Wojciech Jaszczak jaszczw

View GitHub Profile
@jaszczw
jaszczw / machine.js
Last active September 23, 2022 16:25
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jaszczw
jaszczw / structure-rationale.md
Last active May 6, 2019 09:24
Suggested project structure

Redux structure rationale

Goal

We wanted to create an application that is easy to extend and also easy to maintain. In order to achieve that, there has to be clear separation of concerns made by design. We believe that project folder structure is the part where you can enforce many good practices from ground-up. Essenially decreasing the burden on developers.

Introduction

We have couple of building blocks and 'binders' in react-redux application. We create components that represent the view, we create containers that connect views to state and we create actions/sagas/reducers trio to maintain the state. We will also need pages/routes that will display all the containers on one page to user.

Choosing redux-observable or redux-sagas

My task is to compare two libraries which help you resolve same problem, in different manner - Handling async actions in redux applications. I don't want to state which one is better than another but I do want to list pros and cons of each and provide clear feedback which one I have picked and my reasons for it.

There is a nice topic on stack-overflow on the question "Why use Redux-Observable over Redux-Saga?". In this topic there is feedback from creator of react-observable, stating "We don't currently provide any reason redux-observable is better than redux-saga because...it's not. They solve the same problem in extremely similar ways, but have some fundamental differences that only become truly apparent once you use them enough"

In the same response he also points out that deciding for one or another prematurely is unnecessary and even after you can/should still use redux in

@jaszczw
jaszczw / index.html
Last active October 9, 2016 10:24 — forked from Spyryto/index.html
Sum with reference from closure, and without. (http://jsbench.github.io/#b60d1a2e540ba0224b01f330bdb7ec7c) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Sum with reference from closure, and without.</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>