Skip to content

Enhance Service Provider to Support Chained Parsing Methods #858

Open
@maryam4s26

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();

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