Skip to main content

Introduction

At OKcontract we rely on a lot on async data and perform a lot of client-side computations. We use Svelte - a free and open-source front-end component framework. We chose Svelte because its compiler reduces the size of build artifacts and generates more responsive interfaces.

Cells Library

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

We have developed cells - a simplified Functional & Reactive (but not strictly FRP) library inspired by spreadsheets functionalities. Unlike traditional FRP libraries that use a wide array of primitives, OKcontract’s cells library adopts a simpler approach and has much less primitives and allows for more flexibility.

cells simplifies reactive programming for developers and integrates seamlessly with Svelte.

cells focuses on automation as it transparently manages:

  • async calls
  • undefined values
  • errors
  • pointers

Although it is a fully independent library, cells can be a powerful drop-in replacement for Svelte stores.

Design & Philosophy

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.

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.

Main Benefits

  • a global state for all stores (the sheet containing cells)
  • automatic management of async and errors
  • defer computations until values are defined

Source on GitHub

The official GitHub repository: https://github.com/okcontract/cells

Contributions are welcome! Feel free to share feedback and discuss iterations with us via Discord or Twitter.

Dependencies

Cells itself depends on a single graph library. Github: https://github.com/okcontract/graph

License & Support

cells is built by the OKcontract team and is released under the MIT license.

This work is partly supported by the 🔴 Optimism RFG grant.