Very fast optimistic updates
Pluggable authentication
Field-level authorization
<Project>
<Tasks>
<Task>
<Deadline />
<Responsible>
<UserPicture />
<UserName />
</Responsible>
</Task>
</Tasks>
</Project>
projects/1
projects/1/tasks
projects/1/tasks/1
projects/1/tasks/1/deadline
projects/1/responsible
users/mike/name
users/mike/picture/url
const firebase = new Firebase('https://my-app.firebaseio.com');
class User extends React.Component {
componentDidMount() {
const userRef = firebase.child('users/mike');
const listener = userRef.on('value', snapshot => (
this.setState({ user: snapshot.val() });
));
this.unsubscribe = () => userRef.off('value', listener);
}
componentWillUnmount() {
this.unsubscribe();
}
render() {
const { name, phone } = this.state.user;
return <div>Name: {name} ({phone})</div>;
}
}
<User userId="mike">
<Task taskId={user.currentTaskId}>
<Project projectId={task.projectId}>
<UserPicture userId={project.ownerId} />
<UserName userId={project.ownerId} />
</Project>
</Task>
</User>
users/${userId}
tasks/${currentTaskId}
projects/${projectId}
users/${userId}/picture/url
users/${userId}/name
import { connect } from 'react-firebase';
const mapPropsToSubscriptions = () => ({
count: 'count'
});
const mapFirebaseToProps = firebase => ({
setCount: count => firebase.child('count').set(count),
});
const Count = ({ count, setCount }) => (
<div>
<p>Count: {count || 0}</p>
<button onClick={() => setCount(count - 1)}>Decrement</button>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
export default connect(mapPropsToSubscriptions, mapFirebaseToProps)(Count);
(press 'a' to become the game host)