Flyd a functional reactive library...
Tags: reactive, functional, javascript, frp
Published: 2020-12-22 15:44:21

In my previous post I said Kefir is lighter than RxJS.

[Flyd](https://github.com/paldepind/flyd) is lighter than Kefir, perhaps will it fits your needs.

Here is a simple counter in Flyd : [FlydCounter](https://flems.io/#0=N4IgZglgNgpgziAXAbVAOwIYFsZJAOgAsAXLKEAGhAGMB7NYmBvAHgCMBXY4+gAggAmAXgA6ICGmpiAfAGoWAek7d60kWhZwADhjT9hYgE7wOUYjIAMi7brUblPPYNEgBMKSGkBaRQ9WUQOBhYamIIegREEAAmRGiAdhAAXwp0bFwo-AArBCo6BiZiPAUFXjAoAE8BXnUAQjAOSTD6AAo0CmIASmAxWjYs93MQISFiCq0YWjBeGAAPLVpDYjgAMhWxRrdINBgBMVrR8cnprFoBUxgAflPz2Hw5haW4UZbOxDEGpvC0MRGxiamvC2Ehga2BO3w2AEl3BMBaXUQaHw5SqL06SXhhAgcAon1C31ePRAHCCvDgxEMEFCYgA3AA3DCGXhoIR45poNodbpwADuEGI1EIbW61AwpIsiGMxA4hj0bIJ3SlMr0xEhWi0lUx2IojIA5hwcAw4OiaaLSQBGSUwaWysqNfGtNCK63K3iqjDqzXELE4vUGwrGpKmsUwXixJW2+WOigwZ02lVqjUVLW+wz6w3LE1m0MAZit8btX2jMAohjjrvdnuT3u1fozgeDpIALPnXVGOe0S4YKBxy7bK0mUzq0-6jVmQ7wAKytyP29mcrs9nV9hMewc11PpgPj0kANhncrnBM7paXGAoEBXbsTXp9w63Y6D2d48QPhYdHZjp44OovFGNwARquVZDnW25PhOAAcb7tgu36-hA-4ULQV4DretYjvWO6hgAnDBR7FvB56ITitAUAIqE3tWd5gY+jahuaEpAe+84nt2P7EUhZECLilFruhm6jpmQZbBgpjEIg3qGLQPLMjAskAKKGNJhgtGIABiECGOSvC0cQbq0LwAD6jL8hUvBYCS+lsKGGDMvQXg7LqGBhHSoYSIwuowEyaCGbqxgud5bqELobpMGI6JBgyTLEKyBEdleaCmFABxoGsv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NeHwHlPRSOLMQoAfwgWkh4H+BNwJMMA+MZIUAkH5DQwSRnltPtNoEdKODpNhNdPhOJKZOMDgHEm9Kum6BSDtK0AdIDKDJdLdPDKRMYBRMIIGNQiUO9hpHUHUHumoF4WoAAGs4BeAhAyhKhx0mNADCy0AJBqBIQBABAFI3IGAAAZGA1SAAchLKpDLL7IoF4FeCrOkF4EHPLLgBaEZh9nUDcBbIwDbI7MKB7Lp28haAHNLOHNHPHKEEnOnIrJaH7hVgLJ+EkAiH0ijKwCrJrKqHCTyPy1mAoAqE6AnP914FkF4GEzvlHOPONEbNvJ8I9HyzpA-MPO1hMDMHwAkAEQABU5h9JqyILGz1AAgggQh2RIgQBGJEAcxdwvA8wLBkhUgQBMAcA8AGk4BcgaB6B+EigohkguogA)

```js
var clicks = flyd.stream();

inc.addEventListener('click', () => clicks(1));
dec.addEventListener('click', () => clicks(-1));

const sum = flyd.scan((x,y) => x + y, 0, clicks)

sum.map((v) => result.innerText = v)
```