Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Have EventEmitter.sendAndReceive return a Promise #13

Open
basejump opened this issue Dec 3, 2017 · 0 comments
Open

Comments

@basejump
Copy link

basejump commented Dec 3, 2017

Or return a promiseList. We can then use the get or wait to block if we need the results of the event to proceed for certain business logic.

example use need

class CostService implements EventPublisher {
    Long sumWithTax(List<Long> nums) {
        Long result =nums.sum()
        AtomicLong taxTotal = new AtomicLong(0)

        sendAndReceive("calcTaxes", result){ Long tax ->
            taxTotal.addAndGet(tax)
        }.get() //assuming it returns a promisList

        return result + taxTotal.get()
    }
}

Would it be better to add a new method instead of the sendAndReceive? Maybe call it notifyPromise?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant