Skip to content

Instantly share code, notes, and snippets.

@davidbarral
Last active June 14, 2022 08:09
Show Gist options
  • Save davidbarral/41a5cdc9f2216acc15c74df476feca8f to your computer and use it in GitHub Desktop.
Save davidbarral/41a5cdc9f2216acc15c74df476feca8f to your computer and use it in GitHub Desktop.
DI middle 1
const userRepo = require("./repos/user.js");
const defaultRepositories = () => ({ user: userRepo() });
const updateUserPreference = ({ key, value, repositories = defaultRepositories() }) => {
// Do stuff and updade the user.
repositories.user.update(updatedUser);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment