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

Boilerplate for service #1088

Open
SamuelMarks opened this issue Jan 21, 2016 · 0 comments
Open

Boilerplate for service #1088

SamuelMarks opened this issue Jan 21, 2016 · 0 comments

Comments

@SamuelMarks
Copy link

I'm new to Java and was a little taken aback by the verbosity and boilerplate. Was following your sample/services/ExampleIntentService.java and sample/IntentServiceSample.java examples.

Here's some pseudo-code of what I'm after. Maybe you can set me straight?:

Service (background thread?)

class Auth:
    api = wrap('http://foo.com/api/v1/')

    def register(body):
        return api('/register').post(body)

    def login(body):
        return api('/login').post(body)

Frontend

class AuthActivity:
    auth = Auth()
        # logic goes here
            self.auth.login(input.email, input.password).exec((err, res, statusCode, headers) {
                # Alternatively put std logic like this in the service (like an Angular service)
                # new context-specific logic can still be added here; service returns promise
                if err or statusCode/100 > 3:
                    log(statusCode, err.body or res.body)
                else:
                    # handle it
            })
        # logic goes here
            self.auth.register(**input)
        # logic goes here
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

No branches or pull requests

1 participant