getPostData(methodName, args)

Returns `post` (in terms of lifecycle of given method) data which is passed through all of the hooks registered for that particular method.

This method is not available directly (e.g. while importing stuff from stash-it), but it is passed as one of the properties in object for createExtensions method in plugins.

Arguments

  1. methodName (string): method name, any one of the adapter's API (e.g. getItem) or one provided by plugin(s).

  2. args (object): object with arguments that will be passed through all of the hooks registered for methodName for it's post lifecycle part.

Throws

  1. If methodName is not passed as a string, it will throw an error 'methodName' must be a string.

  2. If args is not passed as an object, it will throw an error 'args' must be an object.

  3. If args doesn't contain cacheInstance property (which is a reference to cacheInstance), it will throw an error 'args' must contain 'cacheInstance' property.

Returns

(object): An object, that was passed through all (if any) registered hooks for given methodName. Returned object will (should, see requirements) contain the very same properties as ones passed in args object. Values might change. cacheInstance should be exactly the same reference to cacheInstance (but it eventually depends on the plugins registered).

Example

// used in plugins only
createExtensions: ({ cacheInstance, getPostData }) => {
    return {
        someFunction: (key) => {
            const postData = getPostData('someFunction', { key, cacheInstance });
            // ... do something with that postData
        }
    }
}

(see: writing plugins)

Last updated