question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Add overloads in default templates for reportProgress/observe properties

See original GitHub issue

Example:


  public sendConfirmations(businessDate: string, confirmations?: Confirmation[], observe?: 'body', reportProgress?: boolean): Observable<SendConfirmationsResponse>;
  public sendConfirmations(businessDate: string, confirmations?: Confirmation[[], observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<SendConfirmationsResponse>>;
  public sendConfirmations(businessDate: string, confirmations?: Confirmation[[], observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<SendConfirmationsResponse>>;
  public sendConfirmations(businessDate: string, confirmations?: Confirmation[[], observe: any = 'body', reportProgress: boolean = false): Observable<any> {

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
tajnymagcommented, Jun 22, 2020

@Lonli-Lokli This works for me. resultFor(Body|Response|Events) gets their types correctly.

interface RequestConfig {
    observe?: 'body' | 'response' | 'events',
    reportProgress?: boolean
}
const RequestConfigDefault: RequestConfig = {
    observe: 'body',
    reportProgress: false
}

class ExampleService {
  public sendConfirmations(businessDate: string, confirmations?: Confirmation[], requestConfig?: RequestConfig & { observe?: 'body' }): Observable<SendConfirmationsResponse>;
  public sendConfirmations(businessDate: string, confirmations?: Confirmation[], requestConfig?: RequestConfig & { observe?: 'response' }): Observable<HttpResponse<SendConfirmationsResponse>>;
  public sendConfirmations(businessDate: string, confirmations?: Confirmation[], requestConfig?: RequestConfig & { observe?: 'events' }): Observable<HttpEvent<SendConfirmationsResponse>>;
  public sendConfirmations(businessDate: string, confirmations?: Confirmation[], requestConfig = RequestConfigDefault): Observable<any> {
    if (requestConfig.observe === 'response') {
        return new Observable<HttpResponse<SendConfirmationsResponse>>();
    }

    if (requestConfig.observe === 'events') {
        return new Observable<HttpEvent<SendConfirmationsResponse>>();
    }

    return new Observable<SendConfirmationsResponse>();
  }
}

const example = new ExampleService();
const resultForBody = example.sendConfirmations('2020-22-06', [], { observe: 'body' });
const resultForResponse = example.sendConfirmations('2020-22-06', [], { observe: 'response' });
const resultForEvents = example.sendConfirmations('2020-22-06', [], { observe: 'events' });
1reaction
luisfpgcommented, Jun 22, 2020

Really, reportProgress / observe are not currently handled by the generator. We always generate a parameters object, so we could add a second argument with options. The point is that this will be a significant amount of work, and I don’t currently have time for it. Will leave open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default Report Item Properties - GrapeCity
Report Item Templates. Report Item Templates are regular reports containing report items with properties set to the desired values. You can create a...
Read more >
How can I distinguish overloads of templates with non-type ...
To order the overloads, the compiler transforms each one of them and performs template argument deduction to see if one is more specialized...
Read more >
Overloaded properties and methods - Visual Basic
You create an overloaded member for a class by adding two or more properties or methods with the same name. Except for overloaded...
Read more >
Overload resolution - cppreference.com
If a constructor template or conversion function template has a ... result of the conversion, is added to the set of candidate functions....
Read more >
enable_if - 1.73.0 - Boost C++ Libraries
If this were an error, adding an unrelated function template (that was never ... a true condition argument should enable or disable the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found