本文整理汇总了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);
}
}