Skip to content
Discussion options

You must be logged in to vote

That sounds like a good candidate for a custom Ability.

In Serenity/JS, abilities are the right place to encapsulate any state or integrations your actors need. Instead of trying to pass messages around indirectly, you can give the actor an ability that records incoming messages, and then have your Question read from it.

1. Custom ability

import { Ability } from '@serenity-js/core';

export class ReceiveMessages extends Ability {

    private messages: any[] = [];

    static using(source: SomeMessageSource) {
        const ability = new ReceiveMessages();

        source.onMessage(message => ability.record(message));

        return ability;
    }

    private record(message: any) {

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@apreg
Comment options

Answer selected by jan-molak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants