React components for Peer-* apps.
$ npm install peer-star-react
Higher-order component for creating components that are bound to a specific collaboration.
Example:
import PeerStarApp from 'peer-star-app'
import { withCollaboration } from 'peer-star-react'
function MyComponent ({ collaboration, shared }) {
// gets collaboration and collaboration.shared as arguments
}
const app = PeerStarApp('my app name')
const collaboration = app.collaborate('collaboration name', 'collaboration type', options)
const MyCollaborativeComponent = withCollaboration(collaboration)(MyComponent)
Higher-order component for creating components that are bound to a specific collaboration that will be created from the app.
If options.keys
is a string, the keys will be parsed and passed into the collaboration.
Example:
import PeerStarApp from 'peer-star-app'
import { withCollaborationFromApp } from 'peer-star-react'
function MyComponent ({ collaboration, shared }) {
// gets collaboration and collaboration.shared as arguments
}
const app = PeerStarApp('my app name')
const keys = // some string
const options = { keys }
const MyCollaborativeComponent = withCollaborationFromApp(app, 'collab name', 'collab type', options)(MyComponent)
Higher-order component for creating components that will receive the current collaboration shared value as a property every time it changes.
Example:
import PeerStarApp from 'peer-star-app'
import { withCollaborationLiveValue } from 'peer-star-react'
function MyComponent ({ collaboration, shared, value }) {
console.log('current value is', value)
// gets collaboration, collaboration.shared and collaboration.shared.value() as arguments
}
const app = PeerStarApp('my app name')
const collaboration = app.collaborate('collaboration name', 'collaboration type', options)
const MyCollaborativeComponent = withCollaborationLiveValue(collaboration)(MyComponent)
Higher-order component for creating components that will receive the current collaboration membership as a property every time it changes.
Example:
import PeerStarApp from 'peer-star-app'
import { withCollaborationMembership } from 'peer-star-react'
function MyComponent ({ peers }) {
// peers is a set
console.log('current peers are', Array.from(peers))
}
const app = PeerStarApp('my app name')
const collaboration = app.collaborate('collaboration name', 'collaboration type', options)
const MyCollaborativeComponent = withCollaborationLiveValue(collaboration)(MyComponent)
$ git clone <this repo>
$ cd peer-star-react
$ npm install
$ npm start
MIT