Skip to content

Some minor adjustments#12

Open
yanshcherbakovatredspace wants to merge 7 commits into
developfrom
feature/some-enhancements
Open

Some minor adjustments#12
yanshcherbakovatredspace wants to merge 7 commits into
developfrom
feature/some-enhancements

Conversation

@yanshcherbakovatredspace
Copy link
Copy Markdown
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

Comment thread src/rebound/rebound.ts Outdated
}
}

//This is because a constructor should only be setting crucial variables.
Copy link
Copy Markdown
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

Comment thread src/rebound/rebound.ts
*/
public dispatch: (name: ReboundEvent) => void = this._dispatch;

public connect: () => void = this._connect;
Copy link
Copy Markdown
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

Comment thread src/rebound/rebound.ts Outdated
private _randId: string;
protected _randId: string;

protected _isHammerClient: boolean;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will remove.

Comment thread src/rebound/rebound.ts
* @protected
* @method connect
*/
protected _connect() {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread src/client/client.spec.ts Outdated

describe("Client:", () => {
describe('Client:', () => {
let client: any;
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/client/client.spec.ts Outdated
it('should only be able to add strings as new possible event', () => {
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
Copy Markdown
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

Comment thread src/client/client.spec.ts
client.addEvents('testevent');
client.on('testevent', function() {});
client.on('testevent', function() {
console.log('testevent');
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/main.spec.ts
@@ -1,5 +1,5 @@
describe("This test", function() {
it("will always pass", function() {
describe('This test', function() {
Copy link
Copy Markdown
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