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

Publicize web view progress constants. #17

Merged
merged 1 commit into from
Apr 9, 2014

Conversation

modocache
Copy link
Contributor

Currently, a developer that wants to execute code when the DOM in a web
view has become interactive must write the following:

-(void)webViewProgress:(NJKWebViewProgress *)webViewProgress
        updateProgress:(float)progress
{
    if (progress == 0.5) { /* ... */ }
}

In the above sample, 0.5 is a magic number.

Eliminate the need to use magic numbers by publicizing the constants
used internally: 0.1, 0.5, and 0.9. This allows users to write the
following:

if (progress == kNJKWebViewProgressBeforeInteractiveMaximum) { /* ... */ }

@ninjinkun
Copy link
Owner

Looks good idea, thank you.
However, kNJKWebViewProgressInitialized is difficult name to understand for me. I offer other names.

  • NJKInitialProgressValue
  • NJKHasHtmlViewProgressValue or NJKInteractiveProgressValue
  • NJKFinalProgressValue

I refered WebKit's implementation. https://github.com/WebKit/webkit/blob/2a60b589f6f4e7f91a93164ad64509aeffc0b760/Source/WebCore/loader/ProgressTracker.cpp

Please tell me your naming idea.

Currently, a developer that wants to execute code when the DOM in a web
view has become interactive must write the following:

```objc
-(void)webViewProgress:(NJKWebViewProgress *)webViewProgress
        updateProgress:(float)progress
{
    if (progress == 0.5) { /* ... */ }
}
```

In the above sample, `0.5` is a magic number.

Eliminate the need to use magic numbers by publicizing the constants
used internally: `0.1`, `0.5`, and `0.9`. This allows users to write the
following:

```objc
if (progress == NJKInteractiveProgressValue) { /* ... */ }
```

Add an explanation of the new constants to the README.
@modocache
Copy link
Contributor Author

I like NJKInitialProgressValue, NJKInteractiveProgressValue, and NJKFinalProgressValue. I've amended the commit to use these names. I also added a note to the README.

@ninjinkun
Copy link
Owner

LGTM!

ninjinkun added a commit that referenced this pull request Apr 9, 2014
Publicize web view progress constants.
@ninjinkun ninjinkun merged commit 38b87a4 into ninjinkun:master Apr 9, 2014
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