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
import { createHash } from 'crypto'; | |
// See https://gist.github.com/simon816/afde4d57d5dab8e80120e35596008834 | |
// See https://chromium.googlesource.com/chromium/src/+/master/components/bookmarks/browser/bookmark_codec.cc | |
const regenChecksum = (roots) => { | |
const digest = createHash('md5'); | |
const digestUrl = (url) => { | |
digest.update(url['id'],'ascii'); | |
digest.update(url['name'],'utf16le'); |
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
const pizzaChef = pizzaCookingSubject.subscribe((event: string) => { | |
// Tell chef a step is complete so he can start the next step. | |
if (employeeIsClockedIn && employeeIsResponsibleForTask) { | |
notifyTheEmployeesOfTheStatus(event); | |
} | |
}) | |
const pizzaCustomer = pizzaCustomer.subscribe((event: string) => { | |
// Tell the customer a status update. | |
if (userAllowsNotifications) { | |
notifyTheCustomerOfTheStatus(event); |
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
const pizzaCookingSubject = new Subject(); | |
build() { | |
// Do any steps to build a pizza | |
pizzaCookingSubject.next('Build Done'); | |
} | |
bake() { | |
// Bake your pizza | |
pizzaCookingSubject.next('Baking Done'); | |
} |
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
build() { | |
// Add the Toppings! | |
if (userAllowsNotifications) { | |
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!"); | |
} | |
if (employeeIsClockedIn && employeeIsResponsibleForTask) { | |
notifyTheEmployeesOfTheStatus("Pizza is ready for the oven!"); | |
} | |
} | |
bake() { |
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
build() { | |
// Add the Toppings! | |
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!"); | |
if (employeeIsClockedIn && employeeIsResponsibleForTask) { | |
notifyTheEmployeesOfTheStatus("Pizza is ready for the oven!"); | |
} | |
} |
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
build() { | |
// Add the Toppings! | |
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!"); | |
notifyTheEmployeesOfTheStatus("Pizza is ready for the oven!"); | |
} |
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
build() { | |
// Add the Toppings! | |
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!"); | |
} | |
bake() { | |
// Put it in the oven and let it bake! | |
notifyTheCustomerOfTheStatus("Pizza is done baking!"); | |
} | |
box() { | |
// Let it cool and then box it up! |
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
build() { | |
// Add the Toppings! | |
} | |
bake() { | |
// Put it in the oven and let it bake! | |
} | |
box() { | |
// Let it cool and then box it up! | |
} |