-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Pass options down through utils
This fixes an issue where global util unintentionally shared state between simultaneous async calls. State is now kept only on one specific instance of window, and is passed throughout the app.
- Loading branch information
Showing
12 changed files
with
378 additions
and
313 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import global from './global'; | ||
import { generateConfig } from './utils/config'; | ||
import * as ClipUtils from './utils/clip'; | ||
|
||
export const clipRecipe = async (options) => { | ||
global.options = { | ||
...global.options, | ||
...(options || {}), | ||
}; | ||
global.window = global.options.window; | ||
const config = generateConfig(options); | ||
|
||
return { | ||
imageURL: ClipUtils.clipImageURL(), | ||
title: ClipUtils.clipTitle(), | ||
description: ClipUtils.clipDescription(), | ||
source: ClipUtils.clipSource(), | ||
yield: ClipUtils.clipYield(), | ||
activeTime: ClipUtils.clipActiveTime(), | ||
totalTime: ClipUtils.clipTotalTime(), | ||
ingredients: await ClipUtils.clipIngredients(), | ||
instructions: await ClipUtils.clipInstructions(), | ||
notes: ClipUtils.clipNotes(), | ||
imageURL: ClipUtils.clipImageURL(config), | ||
title: ClipUtils.clipTitle(config), | ||
description: ClipUtils.clipDescription(config), | ||
source: ClipUtils.clipSource(config), | ||
yield: ClipUtils.clipYield(config), | ||
activeTime: ClipUtils.clipActiveTime(config), | ||
totalTime: ClipUtils.clipTotalTime(config), | ||
ingredients: await ClipUtils.clipIngredients(config), | ||
instructions: await ClipUtils.clipInstructions(config), | ||
notes: ClipUtils.clipNotes(config), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.