paritytech / capi

[WIP] A framework for crafting interactions with Substrate chains
https://docs.capi.dev
Apache License 2.0
104 stars 9 forks source link

feat: scope #1084

Closed tjjfvi closed 1 year ago

tjjfvi commented 1 year ago

Resolves #978

harrysolovay commented 1 year ago

Should we provide access to scope within the Rune system? (to enable the fluent API and patterns to decide how/when to cache-invalidate)

import { $accountInfo, polkadotDev } from "@capi/polkadot-dev"
import { $, createDevUsers, Scope } from "capi"

const { alexa } = await createDevUsers()

const scope = new Scope()

const accountInfo = polkadotDev.System.Account.value(alexa.publicKey)

const a = await accountInfo.run(scope)
await delay(30000)
const b = await accountInfo.run(scope) // could be different now
await delay(30000)
const c = await accountInfo.run(scope) // could be different yet again

How might one specify whether to rerun all occurrences, vs. idempotent per run, vs. per scope?

tjjfvi commented 1 year ago

For now, these kinds of questions of out of scope (pun intended) until the rest of the caching/memoization system is more settled.