Cheat Sheet¶

This page serves as a complete reference for the main concepts in Meerkat. You can use this cheat sheet to point you to the right documentation as you learn more about the library.

Concept

Description

mk

The Meerkat CLI, which is used to create and run Meerkat apps. Automatically installed when you install Meerkat.

DataFrame

A Meerkat data frame. Holds structured and unstructured data in a single table.

Column

A column of data in a Meerkat DataFrame. Columns are of 4 main types: ScalarColumn, TensorColumn, DeferredColumn and ObjectColumn.

Store

The way to wrap arbitrary Python objects so their value remains synchronized with the frontend. A Store is a transparent wrapper object that can be used as if it were the Python object it wraps. Stores help Meerkat keep track of objects and data that will participate in reactive functions.

Markable Objects

All Meerkat data objects can be marked or unmarked to indicate how they should be treated by reactive functions. Store objects are marked by default, while objects like DataFrame and Column are not.

obj.mark(), obj.unmark(), obj.marked

Methods and properties to mark and unmark Meerkat data objects.

mark(data)

A shortcut function that returns a marked Meerkat object. Equivalent to Store(data) when data is not a Meerkat data object, and obj.mark() when data is a Meerkat object.

Reactive Function

A function that is automatically re-run by Meerkat when any of its marked inputs change. Along with endpoints, reactive functions are the primary way to define how to respond to a user manipulating the frontend. When called, reactive functions, and their inputs and outputs are added by Meerkat to a directed, acyclic computation graph.

Chained Reactivity

Reactive function calls can be chained, where the output of one function is used as input to another. This defines dependencies between reactive functions, where re-running one function will cause all functions that depend on it to be re-run.

Default Object Reactivity

Meerkat automatically makes all property accesses and certain methods on DataFrame and Column objects reactive. For Store objects, only operations like obj + 1 are reactive by default, unless used in a magic context.

@reactive()

A decorator that is used to create reactive functions in Meerkat. When called, reactive functions will automatically unwrap Store objects, and automatically wrap their return value in a Store if it’s a non-Meerkat object.

Endpoint

A Python function that is run in response to some event on the frontend. The frontend sends the event payload which provides arguments to call the endpoint with. Endpoints in Meerkat are implemented by the Endpoint class.

@endpoint()

A decorator that is used to create endpoints in Meerkat. Functions decorated by @endpoint() should never need to be explicitly called, except in rare circumstances. The decorated function is converted into an Endpoint object.

endpoint.partial(...)

A method that can be called on any Meerkat endpoint in order to bind some its arguments. Returns a new endpoint i.e. a new Endpoint object.

obj.set(value)

A method that can be called on any Meerkat object in order to set its value. This is the only way to trigger reactive functions in Meerkat, and can only be used inside Meerkat endpoints. Reactive functions that depend directly or indirectly (through chained reactivity) on the object that was set will be re-run. When called on non-Store objects like DataFrame or Column, the set value must be a DataFrame or Column object.

@unmarked()

A decorator that ensures that the decorated function is always called with unmarked inputs. Consequently, this function when called will never be reactive, and neither will any function calls within its body, even if they are to reactive functions. Effectively creates a reactivity dead zone.

with unmarked():

A context manager within which all Meerkat objects are made unmarked. Consequently, reactive functions, methods or property accesses used within the context will not behave reactively. Effectively creates a reactivity dead zone.

with magic():

A context manager within which all Store objects automatically have their methods and property accesses made reactive.

Component

The building block for interactive user interfaces in Meerkat. A single component can be as simple as a slider, or as complex as a full data app. All components in Meerkat must have a corresponding component implementation in Svelte.

AnyComponent.on_<event>

An endpoint attribute of a component. If an endpoint is assigned to this attribute, it will be called when the event occurs. This is the only way to set up endpoint calls in Meerkat.

Page

An object that represents a single page in a Meerkat app. Interactive apps must initialize a page, passing in a Component object and ID.