issue: https://linear.app/comm/issue/ENG-4680/refactor-useservercall
We need to refactor useServerCall function (lib/utils/action-utils.js). Before there was only one keyserver, but as we move into multikeyserver world, an action might want to call one specific keyserver, or all of them. For each action we will thus have to define an object of type
export type KeyserverCall<Args: $ReadOnlyArray<mixed>, Return> = { +actionFunc: ActionFunc<Args, Return>, +config: | { +keyserverSelection: 'fanout' } | { +keyserverSelection: 'specific', +keyserverIDExtractor: (...Args) => string, }, };
Where "fanout" means that we call all keyservers, and keyserverIDExtractor is a function that can extract keyserver id from actions arguments.
We cannot completely remove useServerCall function yet, because we would first need to create such objects for all actions. So for now I'm creating useKeyserverCall alongside useServerCall (the name is supposed to be changed
anyway).
In useServerCall implementation memoization was done using a combination of _memoize, createSelector and useMemo. I will do this in the next diff, and provide an explanation of what it does exactly. Thats why
createBoundServerCallsSelector is omitted for now.
See test plan for example of usage