Used within a template function to specify the shape of the target facts.
static match<T>(
template: Partial<T>
): Specification<T>;
type
and predecessorsThis function can be used either as a static or an instance function.
If you already have an instance j
of the Jinaga object, you can call j.match
.
However, if you are defining a library of template functions, you usually do not have the instance j
in scope.
In this situation, you can alias the Jinaga
class to call j.match
as a static function.
import { Jinaga as j } from 'jinaga';
function postsByAuthor(a) {
return j.match({
type: 'Blog.Post',
author: a
});
}
Call suchThat
to attach a condition to the template.
function messagesInChannel(c) {
return j.match({
type: 'Chat.Message',
channel: c
}).suchThat(j.not(messageIsRedacted));
}
function messageIsRedacted(m) {
return j.exists({
type: 'Chat.Message.Redacted',
message: m
});
}