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

Introduce Foxbox API sub-module. Maintain proper services in-memory cache in a separate submodule. Use EventDispatcher for Network, Settings and WebPush sub-modules. (fixes #116). r=gmarty #120

Merged
merged 1 commit into from
Apr 27, 2016

Conversation

azasypkin
Copy link
Member

No description provided.

getURL: Symbol('getURL'),
});

export default class API {
Copy link
Member Author

Choose a reason for hiding this comment

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

One of the ideas I'm still forming in my head is to make API work a bit like DB - it will be initialized immediately, but since all its methods are sync they will wait until user is authenticated and box is discovered....

@gmarty
Copy link
Collaborator

gmarty commented Apr 25, 2016

I left a few comments.
There's a lot in this PR, so the commit name should be updated to account for the bigger scope. It looks good to me.

@azasypkin azasypkin changed the title Remove services that are no longer available. Extract Services module from Foxbox. r=gmarty Introduce Foxbox API sub-module. Maintain proper services in-memory cache in a separate submodule. Use EventDispatcher for Network, Settings and WebPush sub-modules. (fixes #116). r=gmarty Apr 25, 2016
@@ -0,0 +1,195 @@
import { waitFor } from '../../test-utils';
Copy link
Member Author

Choose a reason for hiding this comment

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

Here not all cases covered, just most important and obvious. Should be good enough to start with.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, we need code coverage to know where to focus on writing new unit tests in the future.

@azasypkin
Copy link
Member Author

Should also fix #109, #107 and #99

@azasypkin
Copy link
Member Author

I think it should be ready for review, r+ @gmarty

this._dispatchEvent('box-online', foxboxOnline);

this[p.net] = new Network(this[p.settings]);
this[p.net].on('online-state-changed', (online) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Naming of events is hard :/ Tell me if you have better names for the events!

Copy link
Collaborator

Choose a reason for hiding this comment

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

The more I think about it, the less I like the -changed suffix. An event means a change happened, so that sounds like a redundancy to me. Also, we should take inspiration from the browser event, in this particular case, online seems appropriate.
Likewise, in message-received, a message related event is always going to be about receiving a message, so message looks good enough to me.

I know I suggested preterite verb, but maybe name only event names are better.
Do you have any preferences on that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I know I suggested preterite verb, but maybe name only event names are better.

:) Yeah, I have the same feeling honestly, just followed what we agreed on previously ;) So, remove ``preterite verb` part and we're good? I'm fine with this.

Likewise, in message-received, a message related event is always going to be about receiving a message, so message looks good enough to me.

Not always :) In message app we have message-received message-sent message-failed-to-sent :) But in this case just message should be ok.

Copy link
Member Author

@azasypkin azasypkin Apr 26, 2016

Choose a reason for hiding this comment

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

I think we can try to not be very strict right now, and just follow "lower case + dashes to separate words + common sense" rule and see how it goes :) In some places preterite verb makes a lot of sense.

@gmarty
Copy link
Collaborator

gmarty commented Apr 26, 2016

I did the review (except the tests), but because it's a big PR I want to make sure I take the time to fully understand the changes and what it means for the architecture of the lib.
I'll do that and check the tests this afternoon.

But so far so good. That's a great job!

@azasypkin
Copy link
Member Author

I did the review (except the tests), but because it's a big PR I want to make sure I take the time to fully understand the changes and what it means for the architecture of the lib.
I'll do that and check the tests this afternoon.

Sure, take your time and thanks for the review! I won't touch this PR to until you're fully done so that you have original "snapshot".

services = new Services(dbStub, apiStub, settingsStub);
});

it('getAll returns all currently cached services', function(done) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: you're using double quotes around method names in the api test file above.

@gmarty
Copy link
Collaborator

gmarty commented Apr 27, 2016

OK, I left a couple of nit/question but it looks good to me. r+

…ache in a separate submodule. Use EventDispatcher for Network, Settings and WebPush sub-modules. (fixes #116). r=gmarty
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.

2 participants