Skip to content

Instantly share code, notes, and snippets.

View PCreations's full-sized avatar

Pierre Criulanscy PCreations

View GitHub Profile
@PCreations
PCreations / rxjs-diagrams.md
Last active January 18, 2024 08:52
Super Intuitive Interactive Diagrams to learn combining RxJS sequences by Max NgWizard K
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);
}
import { createRecentArticlesSitemap } from "./recent-articles-sitemap";
export const createHandler = ({ domains }) => {
const recentArticlesSitemap = createRecentArticlesSitemap({
todayDate: new Date(),
});
return () =>
Promise.all(
domains.map(({ domain, language }) =>
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,
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(
@PCreations
PCreations / MessageInput.js
Created August 27, 2017 15:31
Simple message input
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 => {
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: {
import { createHandler } from "./handler";
import { domains } from "./constants/domains";
export const handler = createHandler({ domains });
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 = [
{
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 }),
}) => {