Skip to content

Commit

Permalink
Merge 10b74a8 into 5242c0a
Browse files Browse the repository at this point in the history
  • Loading branch information
filipeversehgi committed Apr 24, 2019
2 parents 5242c0a + 10b74a8 commit 081b2bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions lib/plug.tsx → lib/plug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { Component } from 'react';
import { Subscription } from 'rxjs';
import { TStream, ILifecycle, IPlugState } from './interfaces/plug';


export const plug = <T extends {}>(stream: TStream, lifecycleHooks: Partial<ILifecycle> = {},
) => (WrappedComponent: any) =>
class PluggedComponent extends Component<T, IPlugState> {
) => (WrappedComponent: any) => {
const factory = React.createFactory(WrappedComponent);

return class PluggedComponent extends Component<T, IPlugState> {

_streamSubscription!: Subscription;

Expand Down Expand Up @@ -43,9 +44,10 @@ export const plug = <T extends {}>(stream: TStream, lifecycleHooks: Partial<ILif
const { hasEmmited, innerData } = this.state;

if (hasEmmited) {
return <WrappedComponent {...innerData} />;
return factory({...this.props, ...innerData});
}

return null;
}
}
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "luffie",
"version": "0.1.0",
"version": "0.1.3",
"description": "A state management library for React",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest",
Expand Down

0 comments on commit 081b2bf

Please sign in to comment.