Source : Learn to combine RxJs sequences with super intuitive interactive diagrams
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 { updateBar } = require('../domain/foo/behaviors'); | |
const updateBarUseCaseHandler = ({ getFooOfId, saveFoo }) => async ({ fooId, bar }) => { | |
if (typeof fooId !== typeof '') { | |
throw new Error('fooId must be string'); | |
} | |
const fooData = getFooOfId(); | |
const newFooData = updateBar({ fooData, bar }); | |
await saveFoo(newFooData); | |
} |
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 { createRecentArticlesSitemap } from "./recent-articles-sitemap"; | |
export const createHandler = ({ domains }) => { | |
const recentArticlesSitemap = createRecentArticlesSitemap({ | |
todayDate: new Date(), | |
}); | |
return () => | |
Promise.all( | |
domains.map(({ domain, language }) => |
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 { FooData } = require('./data'); | |
const updateBar = ({ fooData, bar }) => { | |
if (typeof bar !== typeof '') { | |
throw new Error('bar should be a valid string'); | |
} | |
return FooData({ | |
...fooData, | |
bar, | |
foobaz: bar.indexOf('?') === -1 ? fooData.foobaz : 42, |
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 React from 'react'; | |
import PropTypes from 'prop-types'; | |
import withState from 'recompose/withState'; | |
import withHandlers from 'recompose/withHandlers'; | |
import compose from 'recompose/compose'; | |
import { graphql } from 'react-apollo'; | |
import SUBMIT_MESSAGE_MUTATION from './SubmitMessage.graphql'; | |
import GET_MESSAGES_QUERY from './GetMessages.graphql'; | |
const enhance = compose( |
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 React from 'react'; | |
import PropTypes from 'prop-types'; | |
import withState from 'recompose/withState'; | |
import withHandlers from 'recompose/withHandlers'; | |
import compose from 'recompose/compose'; | |
const enhance = compose( | |
withState('value', 'updateValue', ''), | |
withHandlers({ | |
onChange: props => 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 { MyVeryUsefulProject } = require('../index'); | |
const { getFooOfId, saveFoo } = require('../infrastructure/inMemory'); | |
describe('Feature: updating bar', () => { | |
describe('scenario: updating bar with a value not containing a "?"', () => { | |
describe('given a foo object in database with the id foo1 and a bar value of "initial bar value"', () => { | |
describe('when updating the bar value to "some new value"', async (done) => { | |
test('then the foo object with id foo1 should have its bar value set to "some new value"', () => { | |
const inMemoryDatabase = { | |
foo1: { |
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 { createHandler } from "./handler"; | |
import { domains } from "./constants/domains"; | |
export const handler = createHandler({ domains }); |
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 { createRecentArticlesSitemap } from "../recent-articles-sitemap"; | |
import { createHandler } from "../handler"; | |
jest.mock("../recent-articles-sitemap"); | |
describe("handler", () => { | |
it("delegates the creation of the sitemap for each domain/language", async () => { | |
// arrange | |
const domains = [ | |
{ |
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 { createIsRecentArticle } from "./is-recent-article"; | |
import { articleToXml } from "./article-to-xml"; | |
import { createExecuteLatestArticlesQuery } from "./execute-latest-articles-query"; | |
import { createS3xmlUploader } from "./s3-xml-uploader"; | |
export const createRecentArticlesSitemap = ({ | |
todayDate, | |
executeLatestArticlesQuery = createExecuteLatestArticlesQuery(), | |
s3xmlUploader = createS3xmlUploader({ bucketName: process.env.S3_BUCKET }), | |
}) => { |
NewerOlder