Skip to content

Move to ES6 #2

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

Closed
wants to merge 8 commits into from
Closed

Move to ES6 #2

wants to merge 8 commits into from

Conversation

hansemannn
Copy link
Member

@hansemannn hansemannn commented Mar 16, 2018

Ready to review! Requires Hyperloop 3.1.0 Beta 2 (or later).

const Mapbox = require('com.mapbox.mapboxsdk.Mapbox');
const Activity = require('android.app.Activity');

Mapbox.getInstance(new Activity(Ti.Android.currentActivity), 'YOUR_MAPBOX_ACCESS_TOKEN');
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this will work correctly here, since it may have to run delayed for the current activity stuff to work. That's why I did it lazily inside the createView call.

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 was hoping it is executed once anything is imported, which seems to work okay. The problem is that there are mapbox API's that do not require a map-view, like geocoders. Maybe do an initialize method? iOS can actually also be configured by code, so I'd remove the plist-key and use one central method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Doing this one:

import MapView from './mapview';
import Annotation from './annotation';

const MGLAccountManager = require('Mapbox/MGLAccountManager');

class Mapbox {
	static initialize(apiKey) {
		if (!apiKey) { throw 'No API-key provided!'; }
		MGLAccountManager.setAccessToken(apiKey);
	}
}

export { Annotation, MapView, Mapbox }

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

Mapbox.getInstance(new Activity(Ti.Android.currentActivity), 'YOUR_MAPBOX_ACCESS_TOKEN');
class Mapbox {
static initialize(apiKey) {
if (!apiKey) { throw 'No API-key provided!'; }
Copy link
Contributor

Choose a reason for hiding this comment

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

You're not supposed to throw raw strings, but wrap them in an Error object:

if (!apiKey) { throw new Error('No API-key provided!'); }


class Mapbox {
static initialize(apiKey) {
if (!apiKey) { throw 'No API-key provided!'; }
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@sgtcoolguy
Copy link
Contributor

I don't have write access, so can't merge. CR seems fine.

@hansemannn
Copy link
Member Author

Thanks for the review @sgtcoolguy! We are blocked by the Hyperloop 3.1.0 release but can merge once released (pending QE testing).

@hansemannn hansemannn closed this Sep 14, 2020
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