Hi !
You can install it through npm: `npm install autobahn-react` (Node.js & Browser support through Browserify).
The presentation was mainly in French, but anyway, you can check the slides
here.
If you don't know what is React, you should check
it (it's a lib to build user interface by components).
I like how by using React and Autobahn, you can build everything as components. Your user interface, your API.
But, I've encountered a lot of boilerplate codes using plain AutobahnJS which I find very common:
While you're connected, you want to become authenticated. You need to close the connection, instantiate a new Connection object with mostly the same parameters except you add an onchallenge function, authid. This is too much, I think (while I understand that the purpose is to expose a generic API).
For example, Meteor.js has a sweet API to inject data into his components:
var MyComponent = ReactMeteor.createClass({
startMeteorSubscriptions: function() {
Meteor.subscribe("players");
},
// Make sure your component implements this method.
getMeteorState: function() {
return {
playerCount: Players.find().count(),
...
};
}
});
In your state, you'll have playerCount updated whenever someone publish to players.
I wanted the same with AutobahnReact, so you can do:
```js
var MyComponent = AutobahnReact.Decorators.requireSubscriptions(class extends React.Component {
static observeSubscriptions() {
return {
messages: { route: 'com.example.new_messages', store: true }
}
}
});
```
And then, you'll have injected in your props a data object which contains a messages object.
But this is not all.
Authentication is made very simple, you only have to call: `AutobahnReact.Auth.logIn` or `AutobahnReact.Auth.signUp`, it returns a promise.
Authorization also is made very simple, you can have a JSX component (*) which gives you the ability to write that:
```js
...
render() {
return (
<AutobahnReact.Auth.RolePolicy roleMustBe="admin">
<DeleteButton />
</AutobahnReact.Auth.RolePolicy />
);
}
```
(*) : The component is yet to be ready!
Currently, there is a chat example and an "authflow" example in the repo, but instructions are missing on a lot of things, and it's quite in a mess.
Anyway, I hope it is helpful to the folks who are struggling with React and Autobahn, and maybe others who are wondering if they should switch from AngularJS to React or Ember to React or anything.
For a little bit of history and context, this "micro-lib" was at first created for my personal use in my code, because I found that I was rewriting a lot of things using AutobahnJS in my web app.
I think that I was not the only one to feel like that, so I've tried to give a little something to this community which gave me a lot (WAMP, AutobahnPython, AutobahnJS, Crossbar.io).
And I accept with pleasure any pull requests to improve furthermore the code, and I'll do my best to fix any issues you may encounter using AutobahnReact.
Kind regards,
Raito Bezarius.