Skip to content

Instantly share code, notes, and snippets.

@smaldini
Created May 18, 2015 12:34
Show Gist options
  • Save smaldini/577718a9c71571b4b364 to your computer and use it in GitHub Desktop.
Save smaldini/577718a9c71571b4b364 to your computer and use it in GitHub Desktop.
return PublisherFactory.create(
(n, s) -> {
long i = 0l;
while (i < n && s.context().get() < elements) {
if(s.isCancelled()) return;
s.onNext(s.context().getAndIncrement());
i++;
}
if(s.context().get() == elements){
s.onComplete();
}
},
s -> new AtomicLong(0L)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment