退出循环而不执行地图或flatMap

时间:2019-05-04 13:10:36

标签: java project-reactor

在迭代Flux代码时,在方法结束时出现问题。

我尝试了所有可能,但没有运气

import React, { Component } from 'react'
import { Router, Route } from 'react-router-dom'
import createHistory from 'history/createBrowserHistory'
import ReactGA from 'react-ga'

const history = createHistory()
history.listen(location => {
    ReactGA.set({ page: location.pathname })
    ReactGA.pageview(location.pathname)
})

export default class AppRoutes extends Component {
    componentDidMount() {
        ReactGA.pageview(window.location.pathname)
    }

    render() {
        return (
            <Router history={history}>
                <div>
                    <Route path="/your" component={Your} />
                    <Route path="/pages" component={Pages} />
                    <Route path="/here" component={Here} />
                </div>
            </Router>
        )
    }
}

这应该在循环内运行到其他方法,但要结束。

1 个答案:

答案 0 :(得分:0)

使用Flux<T> takeWhile(Predicate<? super T> continuePredicate)函数指定“退出”条件。当您提供的谓词返回false时,您将停止使用原始流中的元素。 Link to Flux javadoc