Skip to content

Enhance Service Provider to Support Chained Parsing Methods #858

Description

@maryam4s26

hello @andersevenrud.
I reviewed the section on creating a service provider in the osjs documentation.

// src/client/myprovider.js
export class MyApiServiceProvider
{
  constructor(core, options = {}) {
    this.core = core;
    this.options = options;
  }

  provides() {
    return ['namespace/api'];
  }

  async init() {
    this.core.singleton('namespace/api', () => ({
      greet: name => alert(`Hello ${name}!`)
    }));
  }
}

// src/client/index.js
import {MyApiServiceProvider} from './myprovider.js';

// ...
osjs.register(MyApiServiceProvider);
// ...

This service provider is called as follows:

OSjs.make('namespace/api').greet('World');

But I want to have a service provider that can be called this way:

OSjs.make('namespace/api').greet('World').firstParser();
OSjs.make('namespace/api').greet('World').secoundParser();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions