zooniverse/Panoptes-Front-End — pull request #31 by brian-c (2014-11-21 12:51:32+00:00)
Title: Add a couple components to help with async rendering

It looks like wrapper components might be a better way to manage promises and events than mixins, since a component encapsulates its own lifecycle and state.

**ChangeListener**, given a target emitter object, will re-render whenever a (configurable) change event is emitted. Ran into an issue with children not re-rendering, which is solved by passing in a `handler` function, which is annoying, but not the end of the world.

**PromiseRenderer**, given a promise, a `then` function, and a `catch` function, waits for the promise to resolve and renders with the results of the appropriate function. This is less annoying, since it'll force us to organize different render methods a bit more.

I extracted these from another branch I'm working on, so there are no examples here. Here they are in use:

```cjsx
module.exports = React.createClass
displayName: 'BuildPage'

render: ->

renderAuth: ->

Waiting for signed-in status...

renderUser: (user) ->
if user?

Signed in as: {user.display_name}

Projects

Getting your projects...

Create a new project

else

You’re not signed in.

renderProjectsList: (projects) ->
items = for project in projects

{project.display_name}

{items}

```

Thoughts, @parrish, @aweiksnar?