mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* add types for package 'fluxible' * add fluxible router types * fix tests * fixed annotation * add missing types * fix tsconfig.json * fix for lint * fix lint * fix name of a package * add missing description * delete bad copypaste * add test file * add tests * fix getStore type check
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { DispatcherInterface } from 'dispatchr';
|
|
import { connectToStores, provideContext } from 'fluxible-addons-react';
|
|
import { Fluxible, ComponentContext } from 'fluxible';
|
|
import BaseStore = require('fluxible/addons/BaseStore');
|
|
import * as React from 'react';
|
|
|
|
interface HomeProps {
|
|
stringValue: string;
|
|
}
|
|
|
|
class Home extends React.Component<HomeProps, any> {
|
|
constructor(props: HomeProps) {
|
|
super(props);
|
|
}
|
|
}
|
|
|
|
class ExtendedStore extends BaseStore {
|
|
constructor(public dispatcher: DispatcherInterface) {
|
|
super(dispatcher);
|
|
|
|
this.data = "";
|
|
}
|
|
|
|
static storeName = 'ExtendedStore';
|
|
|
|
static handlers = {
|
|
ACTION_NAME: 'actionHandler'
|
|
};
|
|
|
|
private data: string;
|
|
|
|
actionHandler() {
|
|
this.emitChange();
|
|
}
|
|
|
|
setData(data: string): void {
|
|
this.data = data;
|
|
}
|
|
|
|
getData(): string {
|
|
return this.data;
|
|
}
|
|
}
|
|
|
|
// connecting Home react component to ExtendedStore
|
|
const ConnectedComponent = connectToStores(Home, [ExtendedStore], (context: ComponentContext, props: HomeProps) => {
|
|
return {
|
|
stringValue: context.getStore(ExtendedStore).getData(),
|
|
};
|
|
});
|
|
|
|
const ConnectedComponentWithContext = provideContext(ConnectedComponent);
|