Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: effects can spawn new runs, key page and block reads #160

Merged
merged 2 commits into from
Jul 21, 2022

Conversation

harrysolovay
Copy link
Contributor

Let's say you have the following effect:

 const decoded = sys.atom(
  "Anonymous",
  [$key, keysEncoded],
  (keyCodec, keysEncoded) => {
    return keysEncoded.map((keyEncoded) => {
      return keyCodec.decode(U.hex.decode(keyEncoded));
    });
  },
);

You can refactor the impl to a function function...

 const decoded = sys.atom(
  "Anonymous",
  [$key, keysEncoded],
- (keyCodec, keysEncoded) => {
+ function(keyCodec, keysEncoded) {
    return keysEncoded.map((keyEncoded) => {
      return keyCodec.decode(U.hex.decode(keyEncoded));
    });
  },
);

... which gives access to the executor via this:

const decoded = sys.atom(
  "Anonymous",
  [$key, keysEncoded],
  function(keyCodec, keysEncoded) {
+   this.run(anotherEffect); // would likely––in practice––await and use the result
    return keysEncoded.map((keyEncoded) => {
      return keyCodec.decode(U.hex.decode(keyEncoded));
    });
  },
);

Additionally, this PR cleans up the key page and block read effects with appropriate decoding.

@harrysolovay harrysolovay merged commit fd3a5ca into main Jul 21, 2022
@harrysolovay harrysolovay deleted the more-effect-cleanup branch July 21, 2022 08:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant