Skip to content

Instantly share code, notes, and snippets.

@adamzerner
adamzerner / one-way-data-flow-vs-two-way-data-binding.md
Last active April 14, 2020 00:14
One way data flow vs. two way data binding

I would like to understand why one way data flow is "cool", and why two way data binding became "uncool". I could just follow best practices without totally understanding them, but I'd prefer to have a deep understanding of why the best practices are what they are.

I started off having a pretty poor understanding of why one way data flow is "cool" and why two way data binding became "uncool". Over the past week or so I've been doing research. At this point I think I have a decent understanding, but I suspect that there are things I am missing, and I would like to confirm that some beliefs of mine are accurate.

Handling shared state imperatively vs. declaratively

Suppose that you have a really simple toy app that lets you input a name, and says "hi" to that name in different langauges. Eg. you may enter "John Doe" and the app will have different views saying "Hi John Doe", "Holla John Doe", and "Kon'nichiwa John Doe".

The structure of the components probably looks something like this:

@adamzerner
adamzerner / .osx
Last active December 31, 2020 23:07
#!/bin/bash
# ~/.osx — https://mths.be/osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &