本文整理匯總了TypeScript中@grafana/ui/src/components/RefreshPicker/RefreshPicker.isLive函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isLive函數的具體用法?TypeScript isLive怎麽用?TypeScript isLive使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isLive函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: isLive
mapper: (state, action): ExploreItemState => {
const { queryIntervals, refreshInterval } = state;
const { data } = action.payload;
const live = isLive(refreshInterval);
if (!live) {
return state;
}
const newResults = seriesDataToLogsModel([data], queryIntervals.intervalMs);
const rowsInState = sortLogsResult(state.logsResult, state.refreshInterval).rows;
const processedRows = [];
for (const row of rowsInState) {
processedRows.push({ ...row, fresh: false });
}
for (const row of newResults.rows) {
processedRows.push({ ...row, fresh: true });
}
const rows = processedRows.slice(processedRows.length - 1000, 1000);
const logsResult: LogsModel = state.logsResult ? { ...state.logsResult, rows } : { hasUniqueLabels: false, rows };
return {
...state,
logsResult,
};
},
示例2: calculateResultsFromQueryTransactions
mapper: (state, action): ExploreItemState => {
const { queryIntervals, refreshInterval } = state;
const { result, resultType, latency } = action.payload;
const results = calculateResultsFromQueryTransactions(result, resultType, queryIntervals.intervalMs);
const live = isLive(refreshInterval);
if (live) {
return state;
}
return {
...state,
graphResult: resultType === 'Graph' ? results.graphResult : state.graphResult,
tableResult: resultType === 'Table' ? results.tableResult : state.tableResult,
logsResult:
resultType === 'Logs'
? sortLogsResult(results.logsResult, refreshInterval)
: sortLogsResult(state.logsResult, refreshInterval),
latency,
graphIsLoading: live ? true : false,
logIsLoading: live ? true : false,
tableIsLoading: live ? true : false,
showingStartPage: false,
update: makeInitialUpdateState(),
};
},
示例3: isLive
export const sortLogsResult = (logsResult: LogsModel, refreshInterval: string) => {
const rows = logsResult ? logsResult.rows : [];
const live = isLive(refreshInterval);
live ? rows.sort(sortInAscendingOrder) : rows.sort(sortInDescendingOrder);
const result: LogsModel = logsResult ? { ...logsResult, rows } : { hasUniqueLabels: false, rows };
return result;
};
示例4: filter
filter(action => {
if (action.type === resetExploreAction.type) {
return true; // stops all subscriptions if user navigates away
}
if (action.type === updateDatasourceInstanceAction.type && action.payload.exploreId === exploreId) {
return true; // stops subscriptions if user changes data source
}
if (action.type === changeRefreshIntervalAction.type && action.payload.exploreId === exploreId) {
return !isLive(action.payload.refreshInterval); // stops subscriptions if user changes refresh interval away from 'Live'
}
if (action.type === clearQueriesAction.type && action.payload.exploreId === exploreId) {
return true; // stops subscriptions if user clears all queries
}
return action.payload.exploreId === exploreId && action.payload.refId === refId;
}),
示例5: mergeMap
mergeMap((action: ActionOf<StartSubscriptionsPayload>) => {
const { exploreId, dataReceivedActionCreator } = action.payload;
const { datasourceInstance, queries, refreshInterval } = state$.value.explore[exploreId];
if (!datasourceInstance || !datasourceInstance.convertToStreamTargets) {
return NEVER; //do nothing if datasource does not support streaming
}
if (!refreshInterval || !isLive(refreshInterval)) {
return NEVER; //do nothing if refresh interval is not 'LIVE'
}
const request: any = { targets: queries };
return datasourceInstance.convertToStreamTargets(request).map(target =>
startSubscriptionAction({
url: convertToWebSocketUrl(target.url),
refId: target.refId,
exploreId,
dataReceivedActionCreator,
})
);
})