prettier
This commit is contained in:
parent
23d2a80273
commit
a040485193
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
files: '*.json',
|
files: '*.json',
|
||||||
options: {
|
options: {
|
||||||
printWidth: 400,
|
printWidth: 100,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
4
src/index.d.ts
vendored
4
src/index.d.ts
vendored
@ -1142,7 +1142,9 @@ declare module 'react-native-firebase' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BackgroundFetchResultValue = string;
|
type BackgroundFetchResultValue = string;
|
||||||
type CompletionHandler = (backgroundFetchResult: BackgroundFetchResultValue) => void;
|
type CompletionHandler = (
|
||||||
|
backgroundFetchResult: BackgroundFetchResultValue
|
||||||
|
) => void;
|
||||||
|
|
||||||
interface Notifications {
|
interface Notifications {
|
||||||
android: AndroidNotifications;
|
android: AndroidNotifications;
|
||||||
|
@ -20,7 +20,6 @@ import type EventSubscriptionVendor from './EventSubscriptionVendor';
|
|||||||
* EmitterSubscription represents a subscription with listener and context data.
|
* EmitterSubscription represents a subscription with listener and context data.
|
||||||
*/
|
*/
|
||||||
class EmitterSubscription extends EventSubscription {
|
class EmitterSubscription extends EventSubscription {
|
||||||
|
|
||||||
emitter: EventEmitter;
|
emitter: EventEmitter;
|
||||||
listener: Function;
|
listener: Function;
|
||||||
context: ?Object;
|
context: ?Object;
|
||||||
|
@ -32,7 +32,6 @@ const invariant = require('fbjs/lib/invariant');
|
|||||||
* more advanced emitter may use an EventHolder and EventFactory.
|
* more advanced emitter may use an EventHolder and EventFactory.
|
||||||
*/
|
*/
|
||||||
class EventEmitter {
|
class EventEmitter {
|
||||||
|
|
||||||
_subscriber: EventSubscriptionVendor;
|
_subscriber: EventSubscriptionVendor;
|
||||||
_currentSubscription: ?EmitterSubscription;
|
_currentSubscription: ?EmitterSubscription;
|
||||||
|
|
||||||
@ -61,12 +60,14 @@ class EventEmitter {
|
|||||||
* listener
|
* listener
|
||||||
*/
|
*/
|
||||||
addListener(
|
addListener(
|
||||||
eventType: string, listener: Function, context: ?Object): EmitterSubscription {
|
eventType: string,
|
||||||
|
listener: Function,
|
||||||
|
context: ?Object
|
||||||
|
): EmitterSubscription {
|
||||||
return (this._subscriber.addSubscription(
|
return (this._subscriber.addSubscription(
|
||||||
eventType,
|
eventType,
|
||||||
new EmitterSubscription(this, this._subscriber, listener, context)
|
new EmitterSubscription(this, this._subscriber, listener, context)
|
||||||
) : any);
|
): any);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +80,11 @@ class EventEmitter {
|
|||||||
* @param {*} context - Optional context object to use when invoking the
|
* @param {*} context - Optional context object to use when invoking the
|
||||||
* listener
|
* listener
|
||||||
*/
|
*/
|
||||||
once(eventType: string, listener: Function, context: ?Object): EmitterSubscription {
|
once(
|
||||||
|
eventType: string,
|
||||||
|
listener: Function,
|
||||||
|
context: ?Object
|
||||||
|
): EmitterSubscription {
|
||||||
return this.addListener(eventType, (...args) => {
|
return this.addListener(eventType, (...args) => {
|
||||||
this.removeCurrentListener();
|
this.removeCurrentListener();
|
||||||
listener.apply(context, args);
|
listener.apply(context, args);
|
||||||
@ -146,10 +151,13 @@ class EventEmitter {
|
|||||||
* @returns {array}
|
* @returns {array}
|
||||||
*/
|
*/
|
||||||
listeners(eventType: string): [EmitterSubscription] {
|
listeners(eventType: string): [EmitterSubscription] {
|
||||||
const subscriptions: ?[EmitterSubscription] = (this._subscriber.getSubscriptionsForType(eventType): any);
|
const subscriptions: ?[
|
||||||
|
EmitterSubscription,
|
||||||
|
] = (this._subscriber.getSubscriptionsForType(eventType): any);
|
||||||
return subscriptions
|
return subscriptions
|
||||||
? subscriptions.filter(emptyFunction.thatReturnsTrue).map(
|
? subscriptions
|
||||||
function(subscription) {
|
.filter(emptyFunction.thatReturnsTrue)
|
||||||
|
.map(function(subscription) {
|
||||||
return subscription.listener;
|
return subscription.listener;
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
@ -170,7 +178,9 @@ class EventEmitter {
|
|||||||
* emitter.emit('someEvent', 'abc'); // logs 'abc'
|
* emitter.emit('someEvent', 'abc'); // logs 'abc'
|
||||||
*/
|
*/
|
||||||
emit(eventType: string) {
|
emit(eventType: string) {
|
||||||
const subscriptions: ?[EmitterSubscription] = (this._subscriber.getSubscriptionsForType(eventType): any);
|
const subscriptions: ?[
|
||||||
|
EmitterSubscription,
|
||||||
|
] = (this._subscriber.getSubscriptionsForType(eventType): any);
|
||||||
if (subscriptions) {
|
if (subscriptions) {
|
||||||
for (let i = 0, l = subscriptions.length; i < l; i++) {
|
for (let i = 0, l = subscriptions.length; i < l; i++) {
|
||||||
const subscription = subscriptions[i];
|
const subscription = subscriptions[i];
|
||||||
@ -202,7 +212,9 @@ class EventEmitter {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
removeListener(eventType: string, listener) {
|
removeListener(eventType: string, listener) {
|
||||||
const subscriptions: ?[EmitterSubscription] = (this._subscriber.getSubscriptionsForType(eventType): any);
|
const subscriptions: ?[
|
||||||
|
EmitterSubscription,
|
||||||
|
] = (this._subscriber.getSubscriptionsForType(eventType): any);
|
||||||
if (subscriptions) {
|
if (subscriptions) {
|
||||||
for (let i = 0, l = subscriptions.length; i < l; i++) {
|
for (let i = 0, l = subscriptions.length; i < l; i++) {
|
||||||
const subscription = subscriptions[i];
|
const subscription = subscriptions[i];
|
||||||
|
@ -18,7 +18,6 @@ import type EventSubscriptionVendor from './EventSubscriptionVendor';
|
|||||||
* remove its own subscription.
|
* remove its own subscription.
|
||||||
*/
|
*/
|
||||||
class EventSubscription {
|
class EventSubscription {
|
||||||
|
|
||||||
eventType: string;
|
eventType: string;
|
||||||
key: number;
|
key: number;
|
||||||
subscriber: EventSubscriptionVendor;
|
subscriber: EventSubscriptionVendor;
|
||||||
|
@ -20,7 +20,6 @@ import type EventSubscription from './EventSubscription';
|
|||||||
* subscribed to a particular event type.
|
* subscribed to a particular event type.
|
||||||
*/
|
*/
|
||||||
class EventSubscriptionVendor {
|
class EventSubscriptionVendor {
|
||||||
|
|
||||||
_subscriptionsForType: Object;
|
_subscriptionsForType: Object;
|
||||||
_currentSubscription: ?EventSubscription;
|
_currentSubscription: ?EventSubscription;
|
||||||
|
|
||||||
@ -36,10 +35,13 @@ class EventSubscriptionVendor {
|
|||||||
* @param {EventSubscription} subscription
|
* @param {EventSubscription} subscription
|
||||||
*/
|
*/
|
||||||
addSubscription(
|
addSubscription(
|
||||||
eventType: string, subscription: EventSubscription): EventSubscription {
|
eventType: string,
|
||||||
|
subscription: EventSubscription
|
||||||
|
): EventSubscription {
|
||||||
invariant(
|
invariant(
|
||||||
subscription.subscriber === this,
|
subscription.subscriber === this,
|
||||||
'The subscriber of the subscription is incorrectly set.');
|
'The subscriber of the subscription is incorrectly set.'
|
||||||
|
);
|
||||||
if (!this._subscriptionsForType[eventType]) {
|
if (!this._subscriptionsForType[eventType]) {
|
||||||
this._subscriptionsForType[eventType] = [];
|
this._subscriptionsForType[eventType] = [];
|
||||||
}
|
}
|
||||||
@ -93,7 +95,7 @@ class EventSubscriptionVendor {
|
|||||||
* @returns {?array}
|
* @returns {?array}
|
||||||
*/
|
*/
|
||||||
getSubscriptionsForType(eventType: string): ?[EventSubscription] {
|
getSubscriptionsForType(eventType: string): ?[EventSubscription] {
|
||||||
return this._subscriptionsForType[eventType];
|
return this._subscriptionsForType[eventType];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user