本文整理匯總了TypeScript中@ember/object.get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript get函數的具體用法?TypeScript get怎麽用?TypeScript get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了get函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: get
const databaseInstance = (adapter: RealtimeDatabaseAdapter) => {
let database = get(adapter, 'database');
if (!database) {
const app = get(adapter, 'firebaseApp');
const databaseURL = get(adapter, 'databaseURL');
database = app.database(databaseURL);
set(adapter, 'database', database);
}
return database;
}
示例2: get
const setRouteSubscription = (service: RealtimeListenerService, route: Object, unsubscribe: (() => void)|null) => {
const routeSubscriptions = get(service, `routeSubscriptions`);
const existingSubscription = get(routeSubscriptions, route.toString());
if (existingSubscription) { existingSubscription() }
if (unsubscribe) {
routeSubscriptions[route.toString()] = unsubscribe;
} else {
delete routeSubscriptions[route.toString()];
}
}
示例3: get
cachedFirestoreInstance = app.firestore().then(firestore => {
const settings = get(adapter, 'settings');
firestore.settings(settings);
const enablePersistence = get(adapter, 'enablePersistence');
const fastboot = getOwner(adapter).lookup('service:fastboot');
if (enablePersistence && (fastboot == null || !fastboot.isFastBoot)) {
const persistenceSettings = get(adapter, 'persistenceSettings');
firestore.enablePersistence(persistenceSettings).catch(console.warn);
}
return firestore;
});
示例4: function
return function() {
let currentValue = get(obj, prop);
if (isPresent(values)) {
let currentIdx = values.indexOf(currentValue);
let nextIdx = nextIndex(get(values, 'length'), currentIdx);
return set(obj, prop, values[nextIdx]);
}
return set(obj, prop, !currentValue);
};
示例5: get
return Object.keys(this.attrs).reduce((acc: ComponentAttributes, key) => {
const value = get(this, key as keyof this);
acc[key] = value;
return acc;
}, {});
示例6: _trackEvent
/**
* Invokes the metrics trackEvent service with options for the event being tracked
* @memberof TrackUiEvent
*/
_trackEvent(this: TrackUiEvent): void {
const metrics = get(this, 'metrics');
const { category, action, name, value }: IPiwikEvent = getProperties(this, ['category', 'action', 'name', 'value']);
const resolvedOptions = Object.assign({}, { category, action }, !!name && { name }, !!value && { value });
metrics.trackEvent(resolvedOptions);
}
示例7: currentURL
export function currentURL(): string {
const context = getContext();
if (!context || !isApplicationTestContext(context)) {
throw new Error(
'Cannot call `currentURL` without having first called `setupApplicationContext`.'
);
}
let router = context.owner.lookup('router:main');
if (HAS_CURRENT_URL_ON_ROUTER) {
return get(router, 'currentURL');
} else {
return get(router, 'location').getURL();
}
}
示例8: _trackCurrentUser
/**
* On entry into route, track the currently logged in user
* @return {Promise.<void>}
* @private
*/
async _trackCurrentUser() {
const { tracking } = await Configurator.getConfig<undefined>();
// Check if tracking is enabled prior to invoking
// Passes an anonymous function to track the currently logged in user using the singleton `current-user` service
return (
tracking &&
tracking.isEnabled &&
get(this, 'sessionUser').trackCurrentUser(userId => get(this, 'metrics').identify({ userId }))
);
}
示例9: currentRouteName
export function currentRouteName(): string {
const context = getContext();
if (!context || !isApplicationTestContext(context)) {
throw new Error(
'Cannot call `currentRouteName` without having first called `setupApplicationContext`.'
);
}
let router = context.owner.lookup('router:main');
return get(router, 'currentRouteName');
}
示例10: rollbackAttributes
rollbackAttributes() {
let dirtyKeys = this._recordData.rollbackAttributes();
if (get(this, 'isError')) {
this.didCleanError();
}
this.send('rolledBack');
if (this._record && dirtyKeys && dirtyKeys.length > 0) {
this._record._notifyProperties(dirtyKeys);
}
}