Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reafactor(core, websockets): context #106

Merged
merged 13 commits into from Feb 24, 2019

Conversation

Projects
1 participant
@JozefFlakus
Copy link
Member

commented Feb 21, 2019

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the new behavior?

  • More functional way for providing dependencies to Effects. -> Replaced staticInjectorContainer with context API built upon Reader monad.
const root$ = r.pipe(
  r.matchPath('/'),
  r.matchType('GET'),
  r.useEffect((req$, _, { ask }) => req$.pipe(
    // ...
    tap(message => ask(WsServerToken).map(server =>
      server.sendBroadcastResponse({ ...  })),
    ),
    // ...
  )));
  • bind.to -> bindTo :: ContextToken -> ContextReader -> BoundContextReader
createServer({
  // ...
  dependencies: [
    bindTo(WsServerToken)(webSocketServer().run),
  ],
  // ...
});
  • createServer doesn't start listening automatically. You have to run in manually via createServer().run();

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Other information

In order to use httpListener directly connected to http.createServer you have to run Reader context first:

import { createContext } from '@marblejs/core';
import * as http from 'http';
import httpListener from './http.listener';

const httpServer = httpListener
  .run(createContext());
  
export const server = http
  .createServer(httpServer)
  .listen(1337, '127.0.0.1');

@JozefFlakus JozefFlakus added this to the 2.0.0-rc.3 milestone Feb 21, 2019

@JozefFlakus JozefFlakus self-assigned this Feb 21, 2019

@JozefFlakus JozefFlakus added this to In progress in @marblejs/next via automation Feb 21, 2019

@codecov

This comment has been minimized.

Copy link

commented Feb 21, 2019

Codecov Report

Merging #106 into next will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff         @@
##           next   #106   +/-   ##
===================================
  Coverage   100%   100%           
===================================
  Files        87     87           
  Lines      1010   1012    +2     
  Branches     82     84    +2     
===================================
+ Hits       1010   1012    +2
Impacted Files Coverage Δ
...ckages/core/src/effects/effectsMetadata.factory.ts 100% <ø> (ø) ⬆️
packages/core/src/listener/http.listener.ts 100% <100%> (ø) ⬆️
packages/core/src/context/context.factory.ts 100% <100%> (ø)
packages/core/src/index.ts 100% <100%> (ø) ⬆️
.../src/operators/mapToServer/mapToServer.operator.ts 100% <100%> (ø) ⬆️
packages/core/src/server/server.factory.ts 100% <100%> (ø) ⬆️
packages/core/src/server/server.event.ts 100% <100%> (ø) ⬆️
...ackages/core/src/server/server.event.subscriber.ts 100% <100%> (ø) ⬆️
...ages/websockets/src/listener/websocket.listener.ts 100% <100%> (ø) ⬆️
packages/core/src/context/context.token.factory.ts 100% <100%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df5abff...3cf157e. Read the comment docs.

@JozefFlakus JozefFlakus force-pushed the refactor/next/context branch 3 times, most recently from 0238af4 to 55b8e03 Feb 24, 2019

@JozefFlakus JozefFlakus force-pushed the refactor/next/context branch from 55b8e03 to f420724 Feb 24, 2019

@JozefFlakus JozefFlakus force-pushed the refactor/next/context branch from 43e9ae1 to ecb3752 Feb 24, 2019

@JozefFlakus JozefFlakus force-pushed the refactor/next/context branch from ecb3752 to 3cf157e Feb 24, 2019

@JozefFlakus JozefFlakus merged commit 1963b61 into next Feb 24, 2019

2 checks passed

Travis CI - Pull Request Build Passed
Details
codecov/patch 100% of diff hit (target 100%)
Details

@marblejs/next automation moved this from In progress to Done Feb 24, 2019

@JozefFlakus JozefFlakus deleted the refactor/next/context branch Feb 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.