Skip to content

Add Configuration Builder (and tests) #146

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

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

Conversation

jkmassel
Copy link
Contributor

What?

Android uses a configuration builder which is much cleaner around mutability. This PR adds a configuration builder to iOS as well.

Why?

The configuration has concerning mutability – it should never change after it's created because it's injected at the start. Once it starts being consumed, changes to it don't apply elsewhere, so by making it immutable it's harder to use it wrong.

How?

Builder pattern

Testing Instructions

Covered by new unit tests.

@jkmassel jkmassel requested review from dcalhoun and crazytonyli May 30, 2025 17:54
@jkmassel jkmassel added the [Type] Enhancement A suggestion for improvement. label May 30, 2025
@jkmassel jkmassel force-pushed the align/configuration-builder branch 3 times, most recently from 786184c to 77be22f Compare May 30, 2025 18:11
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

At a high level, this makes sense to me. Solid improvements—thank you! Testing the Demo app worked as expected.

This is likely already understood, but building WP-iOS with these changes fails currently. Before merging this, we should open a sibling PR updating the WP-iOS implementation.

That said, I wanted to address the following:

The configuration has concerning mutability – it should never change after it's created because it's injected at the start. Once it starts being consumed, changes to it don't apply elsewhere, so by making it immutable it's harder to use it wrong.

It's not entirely true that mutations do not have an impact at the moment, because we explicitly rely upon mutating the configuration to set the editor settings and start the editor after the host app fetches the settings.

I am quite confident that code could/should be refactored to be less complex. There are a couple of nuances to consider:

  1. We "warm up" the editor on the My Site tab with an empty configuration;
  2. Within init, we initialize the editor configuration and view controller;
  3. And within viewDidLoad, we display an activity indicator and fetch the editor settings.

These nuances could likely be refactored to embrace immutable configuration while retaining the necessary loading sequence.

@jkmassel
Copy link
Contributor Author

jkmassel commented Jun 9, 2025

@dcalhoun – I broadly agree with your comment. IMHO having two methods on the editor like init and updateConfiguration both of which take an immutable configuration would make a ton of sense, and would make it clear that simply updating the configuration object doesn't cause the underlying editor to change in any way.

I'm happy to leave this PR with you, feel free to do with it what you think is best!

@dcalhoun dcalhoun self-assigned this Jun 27, 2025
jkmassel and others added 7 commits July 8, 2025 21:11
@dcalhoun
Copy link
Member

dcalhoun commented Jul 9, 2025

@crazytonyli in addition to help with wordpress-mobile/WordPress-iOS#24662 (comment), I welcome your review of these changes now that I've rebased it atop the latest trunk branch. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants