public RefreshWhenOSGi()

in component-dsl/src/main/java/org/apache/aries/component/dsl/internal/RefreshWhenOSGi.java [30:58]


    public RefreshWhenOSGi(OSGi<T> program, Predicate<T> refresher) {
        super((executionContext, op) -> {
            OSGiResult result = program.run(
                executionContext,
                op.pipe(
                    t -> {
                        OSGiResult osgiResult = op.publish(t);

                        return new OSGiResultImpl(
                            osgiResult::close,
                            () -> {
                                if (refresher.test(t)) {
                                    return true;
                                }

                                return osgiResult.update();
                            }
                        );
                    }
                ));

            return new OSGiResultImpl(
                result::close,
                () -> {
                    result.update(); return false;
                }
            );
        });
    }