- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
76 lines
2.0 KiB
Plaintext
76 lines
2.0 KiB
Plaintext
/**
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @providesModule Deferred
|
|
* @typechecks
|
|
* @flow
|
|
*/
|
|
|
|
/**
|
|
* Deferred provides a Promise-like API that exposes methods to resolve and
|
|
* reject the Promise. It is most useful when converting non-Promise code to use
|
|
* Promises.
|
|
*
|
|
* If you want to export the Promise without exposing access to the resolve and
|
|
* reject methods, you should export `getPromise` which returns a Promise with
|
|
* the same semantics excluding those methods.
|
|
*/
|
|
class Deferred<Tvalue, Treason> {
|
|
_settled: boolean;
|
|
_promise: Promise<any>;
|
|
_resolve: (value: Tvalue) => void;
|
|
_reject: (reason: Treason) => void;
|
|
|
|
constructor() {
|
|
this._settled = false;
|
|
this._promise = new Promise((resolve, reject) => {
|
|
this._resolve = (resolve: any);
|
|
this._reject = (reject: any);
|
|
});
|
|
}
|
|
|
|
getPromise(): Promise<any> {
|
|
return this._promise;
|
|
}
|
|
|
|
resolve(value: Tvalue): void {
|
|
this._settled = true;
|
|
|
|
this._resolve(value);
|
|
}
|
|
|
|
reject(reason: Treason): void {
|
|
this._settled = true;
|
|
|
|
this._reject(reason);
|
|
}
|
|
|
|
catch(onReject?: ?(error: any) => mixed): Promise<any> {
|
|
return Promise.prototype.catch.apply(this._promise, arguments);
|
|
}
|
|
|
|
then(onFulfill?: ?(value: any) => mixed, onReject?: ?(error: any) => mixed): Promise<any> {
|
|
return Promise.prototype.then.apply(this._promise, arguments);
|
|
}
|
|
|
|
done(onFulfill?: ?(value: any) => mixed, onReject?: ?(error: any) => mixed): void {
|
|
// Embed the polyfill for the non-standard Promise.prototype.done so that
|
|
// users of the open source fbjs don't need a custom lib for Promise
|
|
const promise = arguments.length ? this._promise.then.apply(this._promise, arguments) : this._promise;
|
|
promise.then(undefined, function (err) {
|
|
setTimeout(function () {
|
|
throw err;
|
|
}, 0);
|
|
});
|
|
}
|
|
|
|
isSettled(): boolean {
|
|
return this._settled;
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = Deferred; |