via Reactive (in RxJS) and Non-Reactive (in Scala) Snakes And Ladders | Software Artisan’s Blog.
While playing around with RxJS, I thought it would be interesting to create a Snake and Ladders game that I played during my childhood days. A typical game is played by 3-4 players with a board size of 100 cells and a dice. The board has snakes and ladders on it. Rules are very simple; when a player ends up in a position where the ladder starts, it gets a lift to a position where the ladder ends and if a player ends up in a position where a snake’s mouth starts, it gets gulped down by the snake and reach the tail as a new position. Otherwise, the player moves to a new position from the old by the throw of a dice. Players take turn at throwing the dice.
In the reactive version using RxJS, lets start with a generator that would push a player (represented as a value starting from 0 for first player, 1 for second player and so on…) every few milliseconds, in my case 100ms. In the increment function, lets bump up the value by 1 and finally in the ‘Return Value’ function where the generated numbers are cast out by the number of players using mod operator. So if there are 3 players, the first player would start at 0 and the third would have number of 2. I’m using Node.js to run this and have imported the RxJS module. Here is what I ended up creating for starters.
via Authenticable Observables: Build a Reactive App with JWT Auth.
Reactive programming is powerful and is becoming increasingly popular with libraries such as RxJS. We can make a stream out of just about anything, including API communication and authentication. Check out the repo for this tutorial to see the code.
Everyone knows promises can help flatten the JS pyramid of death. But promises aren’t the only solution available. I’ll discuss some more advanced techniques surrounding the flow of information through your application through the use of libraries such as AsyncJS and RxJS. I’ll also talk about how embracing streams can not only alleviate control flow issues, but also improve performance. Finally, we’ll look into how tools such as ZeroMQ and Redis can help to foster asynchronous and event-driven APIs.
via Using React.js & RxJS to Create a Scroll Table with a Dynamic Width | Codementor.
Lots of people have very romantic thoughts about building the perfect web app with everything flowing so smoothly, with very clean definitions of what is to be expected where. A lot of people also believe in creating React components that have all of their JSX in the
render method, where they can be sure that a lot of the other lifecycle events that aren’t too pleasant or “declarative” can be avoided.
Unfortunately, this is not one of those posts. I make heavy use of very ugly parts of React and modify the DOM as I see fit in order to do what is easiest for me to do. And really, if a components shits all over your DOM but still adheres to the component tree and cleans up after itself, was there really shit in the forest? Probably, but let’s not worry about the that for now.
So what could we do next?
Whatever catches fire after JS, I hope it has these features:
- Built-in immutable data structures and immutability by default.
- Literal forms for objects, collections, and primitive types.
- A better default number type for most use cases.
- Custom structural types, including good support for low-level binary types (bonus if we get definable literal syntax).
- Lambdas with closures.
- Functional utility belt built-in. Similar to the RxJS Observable API.
- Native support for object and factory composition. Something like built-in stamps.
- Realtime guarantees for low-latency processing & precision scheduling for apps like gaming, music & video production, DSP, scientific applications, synchronization of distributed systems, etc…
- Minimal syntax, similar to Ruby, Python, or CoffeeScript. Now that I’ve had a chance to get comfortable without curly braces and semicolons everywhere, I feel a lot less confined by syntax.