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

Add StyleManagerProtocol #317

Merged
merged 5 commits into from
May 5, 2021
Merged

Add StyleManagerProtocol #317

merged 5 commits into from
May 5, 2021

Conversation

julianrex
Copy link
Contributor

@julianrex julianrex commented May 4, 2021

PRs must be submitted under the terms of our Contributor License Agreement CLA.

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Write tests for all new functionality. If tests were not written, please explain why. Will be addressed as tail-work
  • Add example if relevant. Updated.
  • Document any changes to public APIs.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Add an entry inside this element for inclusion in the mapbox-maps-ios changelog: <changelog>Refactors existing Style API functions and adds ones that were hidden.</changelog>.
  • Update the migration guide, API Docs, Markdown files - Readme, Developing, etc

Summary of changes

This is part 1 of N PRs introducing a new StyleManagerProtocol and related public API changes.

This PR:

  • adds a public protocol StyleManagerProtocol, which is the Swifty equivalent of Android's StyleManagerDelegate. As part of this effort, existing APIs that were returning a Result type, now throw instead. For example,

    _ = style.removeStyleLayer(forLayerId: "some-id")

    is replaced by

    try style.removeLayer(withId: "some-id")

    This also exposes a number of APIs that were previously access via the "internal" __map property, for example addCustomLayer.

  • Updates related tests and examples.

  • Updates ResourceOptions documentation

  • Metrics build trigger now tries a remote branch with the same name first.

@julianrex julianrex added the breaking change ⚠️ If your pull request introduces a breaking change and updates are required when version is published label May 5, 2021
@julianrex julianrex marked this pull request as ready for review May 5, 2021 14:53
/// - update: Closure that mutates a layer passed to it
/// - Returns: Result type with `.success` if update is successful, `LayerError` otherwise
@discardableResult
public func updateLayer<T: Layer>(id: String, type: T.Type, update: (inout T) -> Void) -> Result<Bool, LayerError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be updated as part of a future PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep.

Comment on lines +39 to +47
case addLayerFailed(String)

/// Remove the style layer from the map failed
case removeStyleLayerFailed(String?)
case removeLayerFailed(String)

/// Setting layer property(s) failed
case setLayerPropertyFailed(String)

/// The layer properties for a layer are nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole file should go away in the future right? Are we planning on wrapping the errors from core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure yet.

func layerExists(withId id: String) -> Bool

/// The ordered list of the current style layers' identifiers and types
var layerIdentifiers: [LayerInfo] { get }
Copy link
Contributor

Choose a reason for hiding this comment

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

How about renaming this to allLayerIdentifiers ?

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'd be good with that. Will tackle in next PR.

@nishant-karajgikar
Copy link
Contributor

A few questions but no blockers.. Thanks for breaking up the work into multiple PRs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ⚠️ If your pull request introduces a breaking change and updates are required when version is published
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants