/**
 * Copyright 2018-present Facebook.
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 * @format
 */

import androidDevice from './androidDevice';
import iOSDevice from './iOSDevice';
import desktopDevice from './desktopDevice';
import application from './application';
import tracking from './tracking';
import server from './server';
import notifications from './notifications';
import plugins from './plugins';
import user from './user';

import {Logger} from '../fb-interfaces/Logger';
import {Store} from '../reducers/index';
import {Dispatcher} from './types';

export default function(store: Store, logger: Logger): () => Promise<void> {
  const dispatchers: Array<Dispatcher> = [
    application,
    androidDevice,
    iOSDevice,
    desktopDevice,
    tracking,
    server,
    notifications,
    plugins,
    user,
  ];
  const globalCleanup = dispatchers
    .map(dispatcher => dispatcher(store, logger))
    .filter(Boolean);
  return () => {
    return Promise.all(globalCleanup).then(() => {});
  };
}

/**
 * Copyright 2018-present Facebook.
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 * @format
 */

import androidDevice from './androidDevice';
import iOSDevice from './iOSDevice';
import desktopDevice from './desktopDevice';
import application from './application';
import tracking from './tracking';
import server from './server';
import notifications from './notifications';
import plugins from './plugins';
import user from './user';

import {Logger} from '../fb-interfaces/Logger';
import {Store} from '../reducers/index';
import {Dispatcher} from './types';
import {notNull} from '../utils/typeUtils';

export default function(store: Store, logger: Logger): () => Promise<void> {
  const dispatchers: Array<Dispatcher> = [
    application,
    store.getState().settingsState.enableAndroid ? androidDevice : null,
    iOSDevice,
    desktopDevice,
    tracking,
    server,
    notifications,
    plugins,
    user,
  ].filter(notNull);
  const globalCleanup = dispatchers
    .map(dispatcher => dispatcher(store, logger))
    .filter(Boolean);
  return () => {
    return Promise.all(globalCleanup).then(() => {});
  };
}

Use androidEnabled setting in dispatcher
Use androidEnabled setting in dispatcher

Summary:
Takes the androidEnabled setting and uses it to gate the android dispatcher.
Enables people without android sdk to use flipper (e.g. iOS engineers).

Reviewed By: priteshrnandgaonkar

Differential Revision: D17829810

fbshipit-source-id: 7d25580e65dee93ebfda7c5cc4c4cea03744e2ca
