Skip to content

Commit

Permalink
README: add CI badge (#17)
Browse files Browse the repository at this point in the history
* README: add CI badge

* github: update node version

* package: format README

* README: wording

* package: update lock

* package: npm run coverage

* github: fix coverall

* README: coverage badge
  • Loading branch information
hbbio committed Feb 5, 2024
1 parent c927d65 commit 0eebe23
Show file tree
Hide file tree
Showing 6 changed files with 460 additions and 32 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/coverall.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on: ["push", "pull_request"]

name: Test Coveralls

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install dependencies
run: npm ci
- name: run coverage
run: npm run coverage
- name: Coveralls
uses: coverallsapp/github-action@v2
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [19.x]
node-version: [20.x]

steps:
- name: "Checkout current repository"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
*.dot
src/*.dot
README.html
coverage
67 changes: 40 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Cells: A Functional & Reactive Programming library
# Cells: Simplified Functional & Reactive Programming

`cells` is a Functional & Reactive Programming (FRP) library inspired by
spreadsheets. This programming paradigm simplifies handling complex, dynamic
data flows. It is particularly useful in scenarios with asynchronous data
![CI](https://github.com/okcontract/cells/actions/workflows/main.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/okcontract/cells/badge.svg?branch=main)](https://coveralls.io/github/okcontract/cells?branch=main)

Functional & Reactive programming (FRP) simplifies handling complex, dynamic
data flows: It is particularly useful in scenarios with asynchronous data
sources, such as user interfaces or real-time data feeds.

![cells are either values or functions](./assets/cells.svg)
`cells` is a simplified Functional & Reactive (but not strictly FRP) library
inspired by spreadsheets.

![cells are either *values* or *functions*](./assets/cells.svg)

`cells` focuses on automation as it transparently manages:

Expand All @@ -15,8 +20,8 @@ sources, such as user interfaces or real-time data feeds.
- pointers

Although it is a fully independent library, `cells` can be a powerful drop-in
replacement for Svelte stores. The build artifacts are currently at 19.5 kB
(6 kB gzipped).
replacement for Svelte stores. The build artifacts are currently at 19.5 kB (6
kB gzipped).

## Walkthrough

Expand Down Expand Up @@ -61,12 +66,13 @@ Note that:
values are defined. If you need to immediately return a value, use `null`
instead.
- At any time, the actual cell value is accessible through `cell.value`
(possibly undefined) but it's advisable to avoid relying on a value that could
be updated at any moment.
(possibly undefined) but it's advisable to avoid relying on a value that
could be updated at any moment.

## Subscriptions

You can define subscribers functions to be called whenever a cell value change.
You can define subscribers functions to be called whenever a cell value
change.

```ts
const cellA = sheet.new(1);
Expand All @@ -81,9 +87,9 @@ unsubscribe();
```

When using `cells` in Svelte files, you can use the `$cell` sugar to subscribe
to a cell value for display. Note that there is a initial `undefined` value when
using that sugar as the reactive subscription are initially output by the Svelte
compiler as `let $cell;`.
to a cell value for display. Note that there is a initial `undefined` value
when using that sugar as the reactive subscription are initially output by the
Svelte compiler as `let $cell;`.

Unlike Svelte, subscriptions are called in transactional batches, i.e. `cells`
wait until all updates are propagated in the `Sheet` to dispatch notifications
Expand Down Expand Up @@ -154,10 +160,11 @@ const counter = proxy.new(0);
counter.update((prev) => prev + 1);
```

Note that `update` functions should return new arrays and objects, for instance
using spread operators `[...prev, new]` and `{...prev, field: new}`.
Note that `update` functions should return new arrays and objects, for
instance using spread operators `[...prev, new]` and `{...prev, field: new}`.

If you need more complex imperative updates, we suggest you to use `immer`:
If you need more complex imperative updates, we suggest you to use
[immer](https://github.com/immerjs/immer):

```typescript
import { produce } from "immer";
Expand All @@ -170,24 +177,30 @@ cell.update((prev) => produce(prev, patch));

# Design & Philosophy

The design and philosophy of cells are influenced by frameworks like `RxJS`,
`MobX`, and `Recoil`, with increased automation. Our focus is to streamline the
developer experience, reduce the boilerplate and complexity often encountered in
state management and reactive programming.
The design and philosophy of `cells` comes from frameworks such as `RxJS`,
`MobX`, and `Recoil`. Our main objective is to enhance developer experience by
simplifying the complexity typically associated with state management and
reactive programming.

We aim for ease of use and correction, so chasing down any bug is our top
priority.

A non-goal is high-performance (we're not a tensor library!): `cells` is
slower than any direct implementation and should not be used for
computationally intensive tasks. However, `cells` optimizes the global
computation within a program, potentially leading to more optimal execution
than can be achieved through imperative computations from manually organized
functions or modules.

# About

`cells` is built at [OKcontract](https://okcontract.com) and is released under
the MIT license.

We aim for ease of use and correction. Chasing down any bug is our top priority.

A non-goal for now is high-performance: `cells` is slower than any direct
implementation and should not be used for computationally intensive tasks.

Contributors are welcome, feel free to submit PRs directly for small changes.
You can also reach out in our [Discord](https://discord.gg/Cun5aF7k) or contact
us on [Twitter](https://x.com/okcontract) in advance for larger contributions.
You can also reach out in our [Discord](https://discord.gg/Cun5aF7k) or
contact us on [Twitter](https://x.com/okcontract) in advance for larger
contributions.

This work is supported in part by a RFG grant from
[Optimism](https://optimism.io).
Loading

0 comments on commit 0eebe23

Please sign in to comment.