Skip to content

Commit

Permalink
Fix the website build
Browse files Browse the repository at this point in the history
118e883 broke autodoc generation because autodoc isn't smart enough to understand some patterns.
I'm working around it by using the same trick as this file was using previously: reassigning the class variable.
  • Loading branch information
gaearon committed Feb 20, 2017
1 parent 564126f commit fa62917
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Libraries/AppState/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ const invariant = require('fbjs/lib/invariant');
* AppState is frequently used to determine the intent and proper behavior when
* handling push notifications.
*
* This module depends on the native RCTAppState module. If you don't include it,
* `AppState.isAvailable` will return `false`, and any method calls will throw.
*
* ### App States
*
* - `active` - The app is running in the foreground
Expand Down Expand Up @@ -90,11 +87,12 @@ class AppState extends NativeEventEmitter {

_eventHandlers: Object;
currentState: ?string;
isAvailable: boolean = true;
isAvailable: boolean;

constructor() {
super(RCTAppState);

this.isAvailable = true;
this._eventHandlers = {
change: new Map(),
memoryWarning: new Map(),
Expand Down Expand Up @@ -213,10 +211,13 @@ class MissingNativeAppStateShim extends EventEmitter {
}
}

// Guard against missing native module by throwing on first method call.
// Keep the API the same so Flow doesn't complain.
const appState = RCTAppState
? new AppState()
: new MissingNativeAppStateShim();
// This module depends on the native `RCTAppState` module. If you don't include it,
// `AppState.isAvailable` will return `false`, and any method calls will throw.
// We reassign the class variable to keep the autodoc generator happy.
if (RCTAppState) {
AppState = new AppState();
} else {
AppState = new MissingNativeAppStateShim();
}

module.exports = appState;
module.exports = AppState;

0 comments on commit fa62917

Please sign in to comment.