Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

docs(operators): Add documentation for bufferCount #239

Merged

Conversation

DiedrikDM
Copy link
Contributor

Add documentation for bufferCount to close #110

@codecov-io
Copy link

codecov-io commented Jan 24, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@d2a1d94). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #239   +/-   ##
=========================================
  Coverage          ?   77.14%           
=========================================
  Files             ?       15           
  Lines             ?      175           
  Branches          ?        7           
=========================================
  Hits              ?      135           
  Misses            ?       40           
  Partials          ?        0

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 d2a1d94...047c8c5. Read the comment docs.

Add documentation for bufferCount to close ReactiveX#110

const clicks$ = fromEvent(document, 'click');
const buffered$ = clicks$.pipe(
map(e => {return {X: e.clientX, Y: e.clientY};}),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really part of the bufferCount operator, but it might be a better idea to remove the map operator and use the fromEvent's selector argument.

const clicks$ = fromEvent(document, 'click', e => {return {X: e.clientX, Y: e.clientY};});

Nitpick:
Personally, I'm not a fan of using single line functions like this:
e => {return {X: e.clientX, Y: e.clientY};}

What about:

const clicks$ = fromEvent(document, 'click', e => ({X: e.clientX, Y: e.clientY})); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used that single line format because the curly braces for creating the object would throw errors from the compiler. I had no idea you could use the parentheses to solve that 👍
And I'm used to the map function to select the correct parts of the object, but for clarity I actually prefer your solution...
so thanks @frederikprijck 👍 !


const clicks$ = fromEvent(document, 'click');
const buffered$ = clicks$.pipe(
map(e => {return {X: e.clientX, Y: e.clientY};}),
Copy link

@frederikprijck frederikprijck Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark as below (regarding both the selector argument and the single-lined function).

import { fromEvent } from 'rxjs/observable/fromEvent';
import { map, bufferCount } from 'rxjs/operators';

const clicks$ = fromEvent(document, 'click');
Copy link

@frederikprijck frederikprijck Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see other source code not using the $ suffix. @ladyleet Is there any guideline for the docs? I think it's a good idea to use the same approach for every example. I'm a fan of using the suffix, just not sure what the docs guidelines are.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am generally don't use $ - but I will look through docs/discuss and update about the guidelines and document them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to use the $ as a suffix as well (as you can see) but I value consistency in coding higher... So I'll change the code to follow the other existing examples for now and we'll see later if we ever want to refactor it!

'operatorType': 'transformation'
name: 'bufferCount',
operatorType: 'transformation',
signature: ` bufferCount(bufferSize: number, startBufferEvery: number): Observable<T[]>`,
Copy link
Member

@niklas-wortmann niklas-wortmann Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Furthermore we should genrally discuss whether using generics in method signature or not. @ashwin-sureshkumar, @ladyleet , @btroncone

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So please remove generic

Added example console output as a comment on the examples for jsbin as well as for inline examples.
The package.json has a reverted angular-cli dependency so it is only defined in one PR from now on!
@DiedrikDM DiedrikDM force-pushed the docs-transformation-bufferCount branch from 78bb829 to 3e0f360 Compare January 26, 2018 10:53
'operatorType': 'transformation'
name: 'bufferCount',
operatorType: 'transformation',
signature: ` bufferCount(bufferSize: number, startBufferEvery: number): Observable<T[]>`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So please remove generic

The comment containing the expected output needs to be put below the subscription. I have also
updated the method signature to remove the generic type.
@DiedrikDM DiedrikDM force-pushed the docs-transformation-bufferCount branch from b2baf0d to ebfd33c Compare January 26, 2018 15:55
Copy link
Member

@niklas-wortmann niklas-wortmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ashwin-sureshkumar ashwin-sureshkumar merged commit 494bfa2 into ReactiveX:master Feb 5, 2018
@DiedrikDM DiedrikDM deleted the docs-transformation-bufferCount branch February 6, 2018 13:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add docs for operator : transformation - bufferCount
7 participants