Bug 1541631 - Part 5: Remove exitEarly option from memoizableAction since it isn't needed. r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D42030

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Logan Smyth 2019-08-15 21:45:50 +00:00
Родитель 98281d7b19
Коммит 463cc14e60
4 изменённых файлов: 13 добавлений и 22 удалений

Просмотреть файл

@ -139,14 +139,17 @@ export const loadSourceText: MemoizedAction<
{ cx: Context, source: Source },
?Source
> = memoizeableAction("loadSourceText", {
exitEarly: ({ source }) => !source,
hasValue: ({ source }, { getState }) => {
return !!(
getSource(getState(), source.id) &&
getSourceWithContent(getState(), source.id).content
return (
!source ||
!!(
getSource(getState(), source.id) &&
getSourceWithContent(getState(), source.id).content
)
);
},
getValue: ({ source }, { getState }) => getSource(getState(), source.id),
getValue: ({ source }, { getState }) =>
source ? getSource(getState(), source.id) : null,
createKey: ({ source }, { getState }) => {
const epoch = getSourcesEpoch(getState());
return `${epoch}:${source.id}`;

Просмотреть файл

@ -43,9 +43,10 @@ type Args = { cx: Context, source: Source };
export const setSymbols: MemoizedAction<Args, ?Symbols> = memoizeableAction(
"setSymbols",
{
exitEarly: ({ source }) => source.isWasm,
hasValue: ({ source }, { getState }) => hasSymbols(getState(), source),
getValue: ({ source }, { getState }) => getSymbols(getState(), source),
hasValue: ({ source }, { getState }) =>
source.isWasm || hasSymbols(getState(), source),
getValue: ({ source }, { getState }) =>
source.isWasm ? null : getSymbols(getState(), source),
createKey: ({ source }) => source.id,
action: ({ cx, source }, thunkArgs) => doSetSymbols(cx, source, thunkArgs),
}

Просмотреть файл

@ -68,9 +68,6 @@ import type { DebuggeeState } from "./debuggee";
import { uniq } from "lodash";
export type SourcesMap = { [SourceId]: Source };
type SourcesContentMap = {
[SourceId]: AsyncValue<SourceContent> | null,
};
export type SourcesMapByThread = { [ThreadId]: SourcesMap };
export type BreakpointPositionsMap = { [SourceId]: BreakpointPositions };

Просмотреть файл

@ -6,12 +6,8 @@
import type { ThunkArgs } from "../actions/types";
export type MemoizedAction<
Args,
Result
> = Args => ThunkArgs => Promise<?Result>;
export type MemoizedAction<Args, Result> = Args => ThunkArgs => Promise<Result>;
type MemoizableActionParams<Args, Result> = {
exitEarly?: (args: Args, thunkArgs: ThunkArgs) => boolean,
hasValue: (args: Args, thunkArgs: ThunkArgs) => boolean,
getValue: (args: Args, thunkArgs: ThunkArgs) => Result,
createKey: (args: Args, thunkArgs: ThunkArgs) => string,
@ -22,7 +18,6 @@ type MemoizableActionParams<Args, Result> = {
* memoizableActon is a utility for actions that should only be performed
* once per key. It is useful for loading sources, parsing symbols ...
*
* @exitEarly - if true, do not attempt to perform the action
* @hasValue - checks to see if the result is in the redux store
* @getValue - gets the result from the redux store
* @createKey - creates a key for the requests map
@ -49,15 +44,10 @@ export function memoizeableAction<Args, Result>(
getValue,
createKey,
action,
exitEarly,
}: MemoizableActionParams<Args, Result>
): MemoizedAction<Args, Result> {
const requests = new Map();
return args => async (thunkArgs: ThunkArgs) => {
if (exitEarly && exitEarly(args, thunkArgs)) {
return;
}
if (hasValue(args, thunkArgs)) {
return getValue(args, thunkArgs);
}