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

Some minor adjustments #12

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

yanshcherbakovatredspace
Copy link
Contributor

  • Decoupling constructor so it only sets the crucial variables
  • Adding method connect so it can be overridden in case there's a different way that an application is connected to. An extra step will then be required:
    rebound.connect()
  • Making some properties and methods protected so they can be used in sub-classes

}
}

//This is because a constructor should only be setting crucial variables.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add proper JSDoc comments here

@@ -158,4 +166,6 @@ export class Rebound {
* @method dispatch
*/
public dispatch: (name: ReboundEvent) => void = this._dispatch;

public connect: () => void = this._connect;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the JSDoc comment here

private _randId: string;
protected _randId: string;

protected _isHammerClient: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is an unused variable... I would suggest adding the "no-unused-variable" property to tslint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👕 Should remove this one as ClientType provides a way to tell HammerSpace that it's not a HammerSpace instance on the other side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove.

* @protected
* @method connect
*/
protected _connect() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add tests for this please and thank you 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we changed the constructor parameter the test cases need to be adjusted, will adjust them along with the unit tests for _connect

@lmckeen
Copy link
Contributor

lmckeen commented Jan 8, 2018

rebound = new Hammer.Rebound({ id: 'appContainer', client: client, autoConnect: false });

make a small refactor so the user will now create a rebound object like above.
id and client are required and autoConnect is not required as it will have a default of true, this is to have less setup and to make it less confusing for the user. if autoConnect is false the user will have to make a call to rebound.connect();

Thanks 🙂

…d as modules, creating a union of types so addEvents accepts a single string and an array decoupling constructor to only set crucial variables and creating a connect method so it can be overridden.
@SmithAF SmithAF requested a review from Connor93 April 26, 2018 17:23
@@ -1,28 +1,28 @@
import { Client } from './client';
import { Rebound } from '../rebound/rebound';

describe("Client:", () => {
describe('Client:', () => {
let client: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

were you not able to remove this any too ?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I do then the tests will fail because in typescript you should not be able to access them.

let numOfKeysBefore = Object.keys(client._events).length;
let eventTypes = [1, [], {}, 1.2, undefined, null, true];
let eventTypes = [1, [], {}, 1.2, undefined, undefined, true];
Copy link
Contributor

Choose a reason for hiding this comment

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

this null was here as a test case for one of the different types of data that could be thrown at it

expect(client._events.hasOwnProperty('testevent')).toBe(false);

client.addEvents('testevent');
client.on('testevent', function() {});
client.on('testevent', function() {
console.log('testevent');
Copy link
Contributor

Choose a reason for hiding this comment

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

is this so it does not yell at you for having an empty function? because this console.log is not required as it only checking to see if the property is actually there and not what the data is

Copy link
Contributor

Choose a reason for hiding this comment

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

yep just to remove a error

src/main.spec.ts Outdated
@@ -1,5 +1,5 @@
describe("This test", function() {
it("will always pass", function() {
describe('This test', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add a comment to this so people know why this is here and that it should not be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants