Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diversity #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
},
"homepage": "https://github.com/kibin/cycle-example-who-to-follow#readme",
"dependencies": {
"@cycle/core": "^6.0.0",
"@cycle/dom": "^8.0.0",
"@cycle/http": "^7.0.0",
"@cycle/isolate": "^1.1.1",
"@cycle/dom": "^10.0.5",
"@cycle/http": "^9.0.2",
"@cycle/isolate": "^1.4.0",
"@cycle/rx-run": "^7.0.0",
"autoprefixer": "^6.2.1",
"ramda": "^0.18.0",
"rx": "^4.0.7"
"rx": "^4.0.7",
"xstream": "^5.1.0"
},
"devDependencies": {
"autoprefixer": "^6.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/dialogues/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const splitUsers = users =>
const request = actions => actions.refresh$
.map(_ => ({
url: `https://api.github.com/users?since=${rand(50000)}`,
key: `users`,
category: `users`,
headers: auth
}))

Expand All @@ -36,7 +36,7 @@ const intent = DOM => ({

const model = (actions, HTTP) =>
Observable.combineLatest(
getJSON({ key: `users` }, HTTP),
getJSON(`users`, HTTP),
actions.refresh$,
identity,
)
Expand Down
8 changes: 4 additions & 4 deletions src/dialogues/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const request = (actions, props$) => actions.close$
.withLatestFrom(props$, (idx, { users }) => users[idx])
.map(user => user ? {
url: user.url,
key: `user`,
category: `user`,
headers: auth
} : {})

Expand All @@ -30,7 +30,7 @@ const intent = DOM => ({

const model = (actions, HTTP, props$) =>
Observable.combineLatest(
getJSON({ key: `user` }, HTTP),
getJSON(`user`, HTTP),
props$.map(props => props.users),
actions.close$.map((_, idx) => idx),
(user, users, much) => ({
Expand All @@ -47,8 +47,8 @@ const view = state$ => state$
div(`.user-loader`, `Loading...`),
user =>
div(`.user`, [
a(`.user-content`, { href: prop(`html_url`, user) }, [
img(`.user-pic`, { src: prop(`avatar_url`, user) }),
a(`.user-content`, { props: { href: prop(`html_url`, user) } }, [
img(`.user-pic`, { props: { src: prop(`avatar_url`, user) } }),

span(`.user-description`, [
span(`.user-name`, prop(`name`, user)),
Expand Down
7 changes: 5 additions & 2 deletions src/helpers/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { prop } from 'ramda'

import { firstKey, firstVal, eqToProp } from './common'

export function getJSON(by, request$) {
return getJSONHTTP(by, request$)
export function getJSON(by, HTTP) {
return HTTP
.select(by)
.mergeAll()
.map(prop(`body`))
}

function getJSONHTTP(by, request$) {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './index.styl'

import { run } from '@cycle/core'
import { run } from '@cycle/rx-run'
import { makeDOMDriver } from '@cycle/dom'
import { makeHTTPDriver } from '@cycle/http'

Expand All @@ -16,7 +16,7 @@ function main(sources) {
}

const { sinks, sources } = run(main, {
DOM: makeDOMDriver(`#content`),
DOM: makeDOMDriver(`#content`, { transposition: true }),
HTTP: makeHTTPDriver(),
})

Expand Down