Unwalled.Garden

Status: DRAFT. Part of the upcoming Beaker Browser 0.9 release.

Reactions API

Reactions are emojis which can be attached to any arbitrary URL (the “topic”). They’re similar to “likes” but much more general.


import {reactions} from 'dat://unwalled.garden/index.js'

// read
await reactions.list({
  filters: {authors, topics, visiblity},
  sortBy,
  offset,
  limit,
  reverse
})
await reactions.tabulate(topic, {
  filters: {authors, visiblity}
})

// write
await reactions.add(topic, emoji)
await reactions.remove(topic, emoji)

Reaction

The values returned by reaction functions will fit the following object shape:

Attribute Type Usage
url string The URL of the reaction record
topic string The URL that the reaction is attached to
emojis string[] The emojis in the reaction
author Object The site that authored the reaction
 url string
 title string
 description string
 type string[]
visibility string The visibility of the reaction

TabulatedReaction

The values returned by tabulate() will fit the following object shape:

Attribute Type Usage
topic string The URL that the reaction is attached to
emoji string The emoji in the reaction
authors Object[] The sites that authored the reaction
 url string
 title string
 description string
 type string[]

list(opts)

List the reactions on the network.

Param Type Default Usage
opts Object
 filters Object
  authors string|string[] Site URLs
  topics string|string[] URLs
  visibility string 'all' See visibility
 sortBy string 'createdAt' One of: 'createdAt'
 offset number 0
 limit number
 reverse boolean false
Returns
Promise<Reaction[]>

tabulate(topic, opts)

Tabulate the reactions on a topic.

Param Type Default Usage
topic string Topic URL (required)
opts Object
 filters Object
  authors string|string[] Site URLs
  visibility string 'all' See visibility
Returns
Promise<TabulatedReaction[]>

add(topic, emoji)

Add a reaction emoji to the current user’s site. The visibility of the reaction will be copied from the target topic’s record.

Param Type Default Usage
topic string Topic URL (required)
emoji string The emoji to add
Returns
Promise<Reaction>

remove(topic, emoji)

Remove a reaction emoji from the current user’s site.

Param Type Default Usage
topic string Topic URL (required)
emoji string The emoji to remove
Returns
Promise<Reaction>