core.fork0.000000
Creates a forked composition.
Arguments
procrequired
The composition to execute.**
Other arguments passed along to the composition.Return Value
The original input given to fork
.Proc's default mode is to pipe the return value of a proc to the next proc in a composition. core.fork
provides a way to
alter this behavior, calling the forked composition but returning the original input instead of the return value of the
composition. Below, the modified value is persisted to the key-value store but the original input is returned.
something went wrong :(
Forking a composition
Setup
authorization=PROCAUTH
require "proc"
client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
client.core.fork {
client.type.string.upcase >> client.keyv.set(
bucket: "q839ffa7"
)
}.call("hello")
client.core.fork.call("hello", {}, () => {
return client.type.string.upcase.compose(
client.keyv.set(
undefined, q839ffa7
);
);
});
curl "https://proc.run/core/fork" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[[">>", ["%%", "hello"]], ["$$", "proc", ["q839ffa7"]]]]]]'
hello
Values in Proc are immutable, so the return value of core.fork
will always be the given input value.
Stuck? Want to chat about an idea? Join the community on Discord.