Use a BatchManger explictly outside of hooks · Issue #110 · feathersjs-ecosystem/feathers-batch · GitHub
Skip to content

Use a BatchManger explictly outside of hooks #110

Description

@DaddyWarbucks

This is a feature idea and not a bug

I know that I can use the excludes and timeout options to configure the batchClient to behave a certain way. But I have found some use cases where I think it would be nice to use some kind of static method to run some actions in a batch. For example,

// I only want to run these actions in Batch. For whatever reason I don't want them batched with
// other calls, or maybe I am not even using batchClient plugin at all.

const actions = [
  app.service('users').find(),
  app.service('items').find()
];

// Replace this
const results = await Promise.all(actions);

// with this
const results = await BatchManger.all(actions, managerConfig)

This could also be used server side. For example, the Promise.all(actions) does not allow the actions to share a dataloader from feathers-batchloader (unless you manually created one and passed to it, which is a perfectly viable option). Using BatchManger.all(actions, managerConfig) would go through the batch-service hooks and automatically share a dataloader (if setup, of course) and anything else that the batch-service may help out with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions