[flow] Take advantage of flow-typed
This commit is contained in:
parent
2063ad467d
commit
5de1a74429
|
@ -4,7 +4,10 @@ module.exports = {
|
||||||
'commonjs': true,
|
'commonjs': true,
|
||||||
'es6': true
|
'es6': true
|
||||||
},
|
},
|
||||||
'extends': 'eslint:recommended',
|
'extends': [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:flowtype/recommended'
|
||||||
|
],
|
||||||
'globals': {
|
'globals': {
|
||||||
// The globals that (1) are accessed but not defined within many of our
|
// The globals that (1) are accessed but not defined within many of our
|
||||||
// files, (2) are certainly defined, and (3) we would like to use
|
// files, (2) are certainly defined, and (3) we would like to use
|
||||||
|
@ -19,6 +22,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
'sourceType': 'module'
|
'sourceType': 'module'
|
||||||
},
|
},
|
||||||
|
'plugins': [
|
||||||
|
'flowtype'
|
||||||
|
],
|
||||||
'rules': {
|
'rules': {
|
||||||
'new-cap': [
|
'new-cap': [
|
||||||
'error',
|
'error',
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
"clean-css": "^3.0.0",
|
"clean-css": "^3.0.0",
|
||||||
"css-loader": "*",
|
"css-loader": "*",
|
||||||
"eslint": "^3.14.1",
|
"eslint": "^3.14.1",
|
||||||
|
"eslint-plugin-flowtype": "^2.30.0",
|
||||||
"eslint-plugin-import": "^2.2.0",
|
"eslint-plugin-import": "^2.2.0",
|
||||||
"eslint-plugin-jsdoc": "*",
|
"eslint-plugin-jsdoc": "*",
|
||||||
"eslint-plugin-react": "*",
|
"eslint-plugin-react": "*",
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
/* @flow */
|
||||||
|
|
||||||
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
import { conferenceWillLeave } from '../conference';
|
import { conferenceWillLeave } from '../conference';
|
||||||
import JitsiMeetJS from '../lib-jitsi-meet';
|
import JitsiMeetJS from '../lib-jitsi-meet';
|
||||||
|
|
||||||
|
@ -14,10 +18,10 @@ const JitsiConnectionEvents = JitsiMeetJS.events.connection;
|
||||||
/**
|
/**
|
||||||
* Opens new connection.
|
* Opens new connection.
|
||||||
*
|
*
|
||||||
* @returns {Promise<JitsiConnection>}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function connect() {
|
export function connect() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const connectionOptions
|
const connectionOptions
|
||||||
= state['features/base/connection'].connectionOptions;
|
= state['features/base/connection'].connectionOptions;
|
||||||
|
@ -57,7 +61,7 @@ export function connect() {
|
||||||
* @param {string} message - Disconnect reason.
|
* @param {string} message - Disconnect reason.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function connectionDisconnected(message) {
|
function connectionDisconnected(message: string) {
|
||||||
connection.removeEventListener(
|
connection.removeEventListener(
|
||||||
JitsiConnectionEvents.CONNECTION_DISCONNECTED,
|
JitsiConnectionEvents.CONNECTION_DISCONNECTED,
|
||||||
connectionDisconnected);
|
connectionDisconnected);
|
||||||
|
@ -110,7 +114,7 @@ export function connect() {
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function disconnect() {
|
export function disconnect() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const conference = state['features/base/conference'].conference;
|
const conference = state['features/base/conference'].conference;
|
||||||
const connection = state['features/base/connection'].connection;
|
const connection = state['features/base/connection'].connection;
|
||||||
|
@ -148,7 +152,7 @@ export function disconnect() {
|
||||||
* domain: string
|
* domain: string
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setDomain(domain) {
|
export function setDomain(domain: string) {
|
||||||
return {
|
return {
|
||||||
type: SET_DOMAIN,
|
type: SET_DOMAIN,
|
||||||
domain
|
domain
|
||||||
|
@ -167,7 +171,7 @@ export function setDomain(domain) {
|
||||||
* message: string
|
* message: string
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
function _connectionDisconnected(connection, message) {
|
function _connectionDisconnected(connection, message: string) {
|
||||||
return {
|
return {
|
||||||
type: CONNECTION_DISCONNECTED,
|
type: CONNECTION_DISCONNECTED,
|
||||||
connection,
|
connection,
|
||||||
|
@ -205,7 +209,7 @@ function _connectionEstablished(connection) {
|
||||||
* error: string
|
* error: string
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
function _connectionFailed(connection, error) {
|
function _connectionFailed(connection, error: string) {
|
||||||
return {
|
return {
|
||||||
type: CONNECTION_FAILED,
|
type: CONNECTION_FAILED,
|
||||||
connection,
|
connection,
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
/* global APP, JitsiMeetJS */
|
/* @flow */
|
||||||
|
|
||||||
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
import UIEvents from '../../../../service/UI/UIEvents';
|
import UIEvents from '../../../../service/UI/UIEvents';
|
||||||
|
|
||||||
import { SET_DOMAIN } from './actionTypes';
|
import { SET_DOMAIN } from './actionTypes';
|
||||||
import './reducer';
|
import './reducer';
|
||||||
|
|
||||||
|
declare var APP: Object;
|
||||||
|
declare var JitsiMeetJS: Object;
|
||||||
|
|
||||||
const JitsiConferenceEvents = JitsiMeetJS.events.conference;
|
const JitsiConferenceEvents = JitsiMeetJS.events.conference;
|
||||||
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||||
|
|
||||||
|
@ -14,7 +19,7 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||||
* @returns {Promise<JitsiConnection>}
|
* @returns {Promise<JitsiConnection>}
|
||||||
*/
|
*/
|
||||||
export function connect() {
|
export function connect() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
||||||
// XXX Lib-jitsi-meet does not accept uppercase letters.
|
// XXX Lib-jitsi-meet does not accept uppercase letters.
|
||||||
|
@ -88,7 +93,7 @@ export function disconnect() {
|
||||||
* domain: string
|
* domain: string
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setDomain(domain) {
|
export function setDomain(domain: string) {
|
||||||
return {
|
return {
|
||||||
type: SET_DOMAIN,
|
type: SET_DOMAIN,
|
||||||
domain
|
domain
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
/* @flow */
|
||||||
|
|
||||||
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SET_AUDIO_MUTED,
|
SET_AUDIO_MUTED,
|
||||||
SET_CAMERA_FACING_MODE,
|
SET_CAMERA_FACING_MODE,
|
||||||
|
@ -17,7 +21,7 @@ import './reducer';
|
||||||
* muted: boolean
|
* muted: boolean
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setAudioMuted(muted) {
|
export function setAudioMuted(muted: boolean) {
|
||||||
return {
|
return {
|
||||||
type: SET_AUDIO_MUTED,
|
type: SET_AUDIO_MUTED,
|
||||||
muted
|
muted
|
||||||
|
@ -33,7 +37,7 @@ export function setAudioMuted(muted) {
|
||||||
* cameraFacingMode: CAMERA_FACING_MODE
|
* cameraFacingMode: CAMERA_FACING_MODE
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setCameraFacingMode(cameraFacingMode) {
|
export function setCameraFacingMode(cameraFacingMode: CAMERA_FACING_MODE) {
|
||||||
return {
|
return {
|
||||||
type: SET_CAMERA_FACING_MODE,
|
type: SET_CAMERA_FACING_MODE,
|
||||||
cameraFacingMode
|
cameraFacingMode
|
||||||
|
@ -50,7 +54,7 @@ export function setCameraFacingMode(cameraFacingMode) {
|
||||||
* muted: boolean
|
* muted: boolean
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setVideoMuted(muted) {
|
export function setVideoMuted(muted: boolean) {
|
||||||
return {
|
return {
|
||||||
type: SET_VIDEO_MUTED,
|
type: SET_VIDEO_MUTED,
|
||||||
muted
|
muted
|
||||||
|
@ -63,7 +67,7 @@ export function setVideoMuted(muted) {
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function toggleAudioMuted() {
|
export function toggleAudioMuted() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
const muted = getState()['features/base/media'].audio.muted;
|
const muted = getState()['features/base/media'].audio.muted;
|
||||||
|
|
||||||
return dispatch(setAudioMuted(!muted));
|
return dispatch(setAudioMuted(!muted));
|
||||||
|
@ -76,7 +80,7 @@ export function toggleAudioMuted() {
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function toggleCameraFacingMode() {
|
export function toggleCameraFacingMode() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
let cameraFacingMode
|
let cameraFacingMode
|
||||||
= getState()['features/base/media'].video.facingMode;
|
= getState()['features/base/media'].video.facingMode;
|
||||||
|
|
||||||
|
@ -95,7 +99,7 @@ export function toggleCameraFacingMode() {
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function toggleVideoMuted() {
|
export function toggleVideoMuted() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
||||||
const muted = getState()['features/base/media'].video.muted;
|
const muted = getState()['features/base/media'].video.muted;
|
||||||
|
|
||||||
return dispatch(setVideoMuted(!muted));
|
return dispatch(setVideoMuted(!muted));
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
|
/* eslint-disable flowtype/space-before-type-colon */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents further propagation of the events to be handler by a specific event
|
* Prevents further propagation of the events to be handler by a specific event
|
||||||
* handler/listener in the capturing and bubbling phases.
|
* handler/listener in the capturing and bubbling phases.
|
||||||
|
@ -11,7 +13,10 @@
|
||||||
*/
|
*/
|
||||||
export function stopEventPropagation<T>(eventHandler: (ev: Event) => T)
|
export function stopEventPropagation<T>(eventHandler: (ev: Event) => T)
|
||||||
: (ev: Event) => T {
|
: (ev: Event) => T {
|
||||||
return (ev: Event) => {
|
|
||||||
|
/* eslint-enable flowtype/space-before-type-colon */
|
||||||
|
|
||||||
|
return (ev: Event): T => {
|
||||||
const r = eventHandler(ev);
|
const r = eventHandler(ev);
|
||||||
|
|
||||||
// React Native does not propagate the press event so, for the sake of
|
// React Native does not propagate the press event so, for the sake of
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
|
/* @flow */
|
||||||
|
|
||||||
import { combineReducers } from 'redux';
|
import { combineReducers } from 'redux';
|
||||||
|
import type { Reducer } from 'redux';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the dictionary/map which associates a reducer (function) with the
|
||||||
|
* name of he Redux state property managed by the reducer.
|
||||||
|
*/
|
||||||
|
declare type NameReducerMap<S, A> = { [name: string]: Reducer<S, A> };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry for Redux reducers, allowing features to register themselves
|
* A registry for Redux reducers, allowing features to register themselves
|
||||||
* without needing to create additional inter-feature dependencies.
|
* without needing to create additional inter-feature dependencies.
|
||||||
*/
|
*/
|
||||||
class ReducerRegistry {
|
class ReducerRegistry {
|
||||||
|
_elements: NameReducerMap<*, *>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ReducerRegistry instance.
|
* Creates a ReducerRegistry instance.
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +23,9 @@ class ReducerRegistry {
|
||||||
/**
|
/**
|
||||||
* The set of registered reducers, keyed based on the field each reducer
|
* The set of registered reducers, keyed based on the field each reducer
|
||||||
* will manage.
|
* will manage.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @type {NameReducerMap}
|
||||||
*/
|
*/
|
||||||
this._elements = {};
|
this._elements = {};
|
||||||
}
|
}
|
||||||
|
@ -23,7 +37,7 @@ class ReducerRegistry {
|
||||||
* included (such as reducers from third-party modules).
|
* included (such as reducers from third-party modules).
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
combineReducers(additional = {}) {
|
combineReducers(additional: NameReducerMap<*, *> = {}) {
|
||||||
return combineReducers({
|
return combineReducers({
|
||||||
...this._elements,
|
...this._elements,
|
||||||
...additional
|
...additional
|
||||||
|
@ -37,10 +51,10 @@ class ReducerRegistry {
|
||||||
*
|
*
|
||||||
* @param {string} name - The field in the state object that will be managed
|
* @param {string} name - The field in the state object that will be managed
|
||||||
* by the provided reducer.
|
* by the provided reducer.
|
||||||
* @param {Function} reducer - A Redux reducer.
|
* @param {Reducer} reducer - A Redux reducer.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
register(name, reducer) {
|
register(name: string, reducer: Reducer<*, *>) {
|
||||||
this._elements[name] = reducer;
|
this._elements[name] = reducer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue