Eric Vicenti 7b2b0c3c1c Navigation Back support and examples for Android
Summary:
public
- Intro new back action
- Add support in the two main reducers
- Use it in examples to support Android back button
- Disable NavigationCard gestures on Android

Reviewed By: hedgerwang

Differential Revision: D2914154

fb-gh-sync-id: d4dce6538e19613a2ffca21e2e3b2ecaded3d5dc
shipit-source-id: d4dce6538e19613a2ffca21e2e3b2ecaded3d5dc
2016-02-08 20:03:31 -08:00

39 lines
1.1 KiB
JavaScript

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule NavigationFindReducer
* @flow
*/
'use strict';
/*
* NavigationFindReducer takes an array of reducers, and returns a reducer that
* iterates through all of the reducers and the result of the first reducer
* that modifies the input
*/
import type {
NavigationState,
NavigationReducer
} from 'NavigationState';
function NavigationFindReducer(reducers: Array<NavigationReducer>): NavigationReducer {
return function(lastState: ?NavigationState, action: ?any): ?NavigationState {
for (let i = 0; i < reducers.length; i++) {
let reducer = reducers[i];
let newState = reducer(lastState, action);
if (newState !== lastState) {
return newState;
}
}
return lastState;
};
}
module.exports = NavigationFindReducer;