@Test public void flatMap() throws InterruptedException { Try<Future<String>, Throwable> t = acquireNamed("hello") .map(a->{System.out.println("UsingX "+a.getOrElse("")); return a;}) .flatMap(i -> acquireNamed(i.getOrElse("")+ " world") .map(b->{System.out.println("UsingY "+b.getOrElse("")); return b;})) .run(); System.out.println(t); assertTrue(t.isSuccess()); assertThat(t.orElse(null).orElse("-1"),equalTo("HELLO WORLD")); }
public <R> Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f){ FlowableManaged<T> m = this; return new IO.SyncIO.SyncManaged<R>(){ @Override public <R1> IO<R1> apply(Function<? super R, ? extends IO<R1>> fn) { IO<R1> x = m.apply(r1 -> { IO<R1> r = f.apply(r1).apply(r2 -> fn.apply(r2)); return r; }); return x; } }; }
FlowableManaged extends Managed<T> { public <R> Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f){ FlowableManaged<T> m = this; return new IO.SyncIO.SyncManaged<R>(){ @Override public <R1> IO<R1> apply(Function<? super R, ? extends IO<R1>> fn) { IO<R1> x = m.apply(r1 -> { IO<R1> r = f.apply(r1).apply(r2 -> fn.apply(r2)); return r; }); return x; } }; } }
FlowableManaged extends Managed<T> { public <R> Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f){ FlowableManaged<T> m = this; return new IO.SyncIO.SyncManaged<R>(){ @Override public <R1> IO<R1> apply(Function<? super R, ? extends IO<R1>> fn) { IO<R1> x = m.apply(r1 -> { IO<R1> r = f.apply(r1).apply(r2 -> fn.apply(r2)); return r; }); return x; } }; }  }
FlowableManaged extends Managed<T> { public <R> Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f){ FlowableManaged<T> m = this; return new IO.SyncIO.SyncManaged<R>(){ @Override public <R1> IO<R1> apply(Function<? super R, ? extends IO<R1>> fn) { IO<R1> x = m.apply(r1 -> { IO<R1> r = f.apply(r1).apply(r2 -> fn.apply(r2)); return r; }); return x; } }; }  static Managed<T> managed(T just,Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> s, Consumer<T> cleanup); static Managed<T> managed(T just); static Managed<T> of(Supplier<? extends T> s); static Managed<T> of(Publisher<T> acq); final static Semigroup<Managed<T>> semigroup(Semigroup<T> s); final static Monoid<Managed<T>> monoid(Monoid<T> s); static Managed<T> of(IO<T> acquire, Consumer<T> cleanup); static Managed<T> of(IO<T> acquire); static Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all); Managed<R> map(Function<? super T, ? extends R> mapper); Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f); }
FlowableManaged extends Managed<T> { public <R> Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f){ FlowableManaged<T> m = this; return new IO.SyncIO.SyncManaged<R>(){ @Override public <R1> IO<R1> apply(Function<? super R, ? extends IO<R1>> fn) { IO<R1> x = m.apply(r1 -> { IO<R1> r = f.apply(r1).apply(r2 -> fn.apply(r2)); return r; }); return x; } }; }  static Managed<T> managed(T just,Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> s, Consumer<T> cleanup); static Managed<T> managed(T just); static Managed<T> of(Supplier<? extends T> s); static Managed<T> of(Publisher<T> acq); final static Semigroup<Managed<T>> semigroup(Semigroup<T> s); final static Monoid<Managed<T>> monoid(Monoid<T> s); static Managed<T> of(IO<T> acquire, Consumer<T> cleanup); static Managed<T> of(IO<T> acquire); static Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all); Managed<R> map(Function<? super T, ? extends R> mapper); Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f);  }