Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
bigslycat committed Oct 19, 2018
1 parent 9128f19 commit 2c6247d
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 27 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ node_js:
- '10'

before_script:
- cp .npmrc.dist packages/es-observable/.npmrc
- cp .npmrc.dist packages/honeycombs/.npmrc
- cp .npmrc.dist packages/react-honeycombs/.npmrc
- npx lerna bootstrap

jobs:
Expand Down
88 changes: 88 additions & 0 deletions ololo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* @flow */

// eslint-disable-next-line
import { of, empty, fromPromise } from 'most';
import * as hc from 'honeycombs';

const counter = hc.of(0);

const reset = counter.always(0);
const setTo = counter.just();
const increment = counter.transform(state => state + 1);
const decrement = counter.transform(state => state - 1);
const add = counter.apply(payload => state => state + payload);
const subtract = counter.apply(payload => state => state - payload);

increment(); // 1
increment(); // 2
decrement(); // 1
add(5); // 6
subtract(1); // 5
setTo(10); // 10
reset(); // 0

const user = hc.of({ status: 'not logged in' });

const login = user.awaitObservable((_, { username, password }) =>
fromPromise(
fetch('https://example.com/api/auth', {
method: 'POST',
body: JSON.stringify({ username, password }),
})
.then(async response => {
if (!response.ok) return { status: 'auth failed' };

const { assessToken, refreshToken } = await response.json();

return {
status: 'logged in',
username,
assessToken,
refreshToken,
};
})
.catch(() => ({ status: 'auth failed' })),
).startWith({ status: 'logging in' }),
);

const refresh = user.awaitObservable(
state =>
state.status === 'logged in'
? fromPromise(
fetch('https://example.com/api/token', {
method: 'POST',
body: JSON.stringify({ refreshToken: state.refreshToken }),
})
.then(async response => {
if (!response.ok) return { status: 'not logged in' };

const { assessToken, refreshToken } = await response.json();

return {
status: 'logged in',
username: state.username,
assessToken,
refreshToken,
};
})
.catch(() => ({ status: 'auth failed' })),
).startWith({ status: 'logging in' })
: empty(),
);

const logout = user.always({ status: 'not logged in' });

login({ username: '...', password: '...' });
refresh({ refreshToken: '...' });
logout();

const posts = hc.of();

const loadPosts = posts.fromPromise(({ limit = 10, offset = 0 } = {}) =>
fetch(`https://example.com/api/posts?limit=${limit}&offset=${offset}`).then(
response => response.json(),
),
);

loadPosts();
loadPosts({ limit: 20, offset: 50 });
1 change: 0 additions & 1 deletion packages/honeycombs/.npmrc

This file was deleted.

8 changes: 0 additions & 8 deletions packages/honeycombs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ core-js@^2.5.7:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e"
integrity sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==

es-observable@^1.0.0-beta.22:
version "1.0.0-beta.22"
resolved "https://registry.yarnpkg.com/es-observable/-/es-observable-1.0.0-beta.22.tgz#13ac43b5b6f4a0fa1292fb2ef242a6cebb15e2f0"
integrity sha512-IwEAo7XLwcEt9ktG8BqMZiKqK/dtCIqRCJ36QflbfNZQC7BJJDkgc3/6DndnJws709kUWPDLEkOmzF+q2rQcRg==
dependencies:
core-js "^2.5.7"
symbol-observable "^1.2.0"

symbol-observable@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
Expand Down
1 change: 0 additions & 1 deletion packages/react-honeycombs/.npmrc

This file was deleted.

17 changes: 0 additions & 17 deletions packages/react-honeycombs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ core-js@^2.5.7:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e"
integrity sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==

es-observable@^1.0.0-beta.22:
version "1.0.0-beta.22"
resolved "https://registry.yarnpkg.com/es-observable/-/es-observable-1.0.0-beta.22.tgz#13ac43b5b6f4a0fa1292fb2ef242a6cebb15e2f0"
integrity sha512-IwEAo7XLwcEt9ktG8BqMZiKqK/dtCIqRCJ36QflbfNZQC7BJJDkgc3/6DndnJws709kUWPDLEkOmzF+q2rQcRg==
dependencies:
core-js "^2.5.7"
symbol-observable "^1.2.0"

honeycombs@^1.0.0-beta.22:
version "1.0.0-beta.22"
resolved "https://registry.yarnpkg.com/honeycombs/-/honeycombs-1.0.0-beta.22.tgz#a38d4adb58cf0bf12b8cc1e7705e01898da6cce9"
integrity sha512-h4n0S7+vX50xzdrDYf5jUskmFcTH1lLtPaEiIJwJhIXYet4wbzBiTxd+/6UnVv7DBDrxMaMNmxeYBIzppQ7mPg==
dependencies:
core-js "^2.5.7"
es-observable "^1.0.0-beta.22"
symbol-observable "^1.2.0"

symbol-observable@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
Expand Down

0 comments on commit 2c6247d

Please sign in to comment.