Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

feat: @handler support #59

Merged
merged 2 commits into from
Feb 23, 2020
Merged

Conversation

Lellansin
Copy link
Contributor

@Lellansin Lellansin commented Feb 23, 2020

@Provide()
@Func('')     // TODO midway/decorator allow undefined
export class IndexService implements FunctionHandler {
  @Inject()
  ctx; // context

  @Handler('index.entry')
  handler(event) {
    return event.text + this.ctx.text;
  }

  @Handler('index.list')
  getList(event) {
    return event.text + this.ctx.text;
  }
}

the @fun and @handler, can be used in same time. such as:

import { Inject, Provide, Func, Handler } from '@midwayjs/decorator';
import { FunctionHandler } from '../../../../src';

@Provide()
@Func('index.handler')
export class IndexService implements FunctionHandler {
  @Inject()
  ctx; // context

  // index.handler default method
  handler(event) {
    return event.text + this.ctx.text;
  }

  @Handler('index.list')
  getList(event) {
    return event.text + this.ctx.text;
  }
}

@czy88840616 czy88840616 merged commit d0d6e49 into master Feb 23, 2020
@czy88840616 czy88840616 deleted the feat/decorator-handler-support branch February 23, 2020 12:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants