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

thoughts on BOSS pattern for components #38

Open
sdebaun opened this issue Mar 8, 2016 · 2 comments
Open

thoughts on BOSS pattern for components #38

sdebaun opened this issue Mar 8, 2016 · 2 comments

Comments

@sdebaun
Copy link
Owner

sdebaun commented Mar 8, 2016

Bunch Of Stinkin' Streams

WIP

// root/index
export default sources => {
  const response$ = _authedResponse$(sources.auth$, sources.queue$)

  // contains all the user*$ and redirect*$ streams
  // this feels ugly as hell
  const userSources = _userSources(sources.auth$, sources.firebase)

  // OR:
  const {
    userProfileKey$, userProfile$, redirectOnLogin$, redirectOnLogout$, redirectOnUnconfirmed$
  } = _userSources(sources.auth$, sources.firebase)

  const page$ = nestedComponent(
    sources.router.define(_routes),
    {...sources, ...userSources, response$}
  )

  const queue$ = _authedTask$(sources.auth$, glean('queue$',page$))

  const route$ = Observable.merge(
    glean('route$',page$), userSources.redirectUnconfirmed$
  )

  const sinks = glean('DOM', 'auth$', [page$])
  return {queue$, route$, ...sinks}
}

// appframe
export default sources => {
  const appBar = AppBar(sources)
  const sideNav = SideNav(sources)

  const children = [appBar,sideNav]

  const DOM = combineLatestObj({
    appBarDOM: appBar.DOM,
    sideNavDOM: sideNav.DOM,
    headerDOM: sources.headerDOM,
    pageDOM: sources.pageDOM,
  }).map(_DOM)

  const sinks = glean('auth$','queue$','route$',children)
  return {DOM, ...sinks}
}
@sdebaun
Copy link
Owner Author

sdebaun commented Mar 10, 2016

https://github.com/sdebaun/sparks-cyclejs/blob/refactor-appmenu/src/components/AppMenu/index.js

first attempt with this pattern at a lower-level component

@TylorS
Copy link
Collaborator

TylorS commented Mar 11, 2016

I really like the way that the AppMenu looks using this pattern.
It keeps functions small, simple and focused on a single problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants