Skip to content

Instantly share code, notes, and snippets.

@TylorS
Created January 25, 2017 00:41
Show Gist options
  • Save TylorS/62ca0fad3b1dba674f8cc48496102325 to your computer and use it in GitHub Desktop.
Save TylorS/62ca0fad3b1dba674f8cc48496102325 to your computer and use it in GitHub Desktop.
Motorcycle's Future in a nutshell
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
run(main, (sinks) => {
const augmentWithUserRepository = augmentAsStream(UserRepository)
const registerUserSources =
augmentWithUserRepository(RegisterUser)(sinks)
const signInUserSources =
augmentWithUserRepostiory(SignInUser)(sinks)
const user$ = mergeArray([
registerUserSources.user$,
signInUserSources.user$,
])
return { user$ }
})
function augmentAsStream(param, Component) { // curried
return function (sinks) {
return Component({...sinks, param$: just(param) })
}
}
function RegisterUser(sinks) {
const { userRepository$, userCredentials$ } = sinks;
const user$ = combineArray(registerUser, [ userRepository$, userCredentials$ ])
return { user$ }
}
function registerUser (userRepository, userCredential) {
return userRepostiory.registerUser(userCredential);
}
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"babel-runtime": "6.20.0"
}
}
"use strict";
var _extends2 = require("babel-runtime/helpers/extends");
var _extends3 = _interopRequireDefault(_extends2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
run(main, function (sinks) {
var augmentWithUserRepository = augmentAsStream(UserRepository);
var registerUserSources = augmentWithUserRepository(RegisterUser)(sinks);
var signInUserSources = augmentWithUserRepostiory(SignInUser)(sinks);
var user$ = mergeArray([registerUserSources.user$, signInUserSources.user$]);
return { user$: user$ };
});
function augmentAsStream(param, Component) {
// curried
return function (sinks) {
return Component((0, _extends3.default)({}, sinks, { param$: just(param) }));
};
}
function RegisterUser(sinks) {
var userRepository$ = sinks.userRepository$;
var userCredentials$ = sinks.userCredentials$;
var user$ = combineArray(registerUser, [userRepository$, userCredentials$]);
return { user$: user$ };
}
function registerUser(userRepository, userCredential) {
return userRepostiory.registerUser(userCredential);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment