Site icon Android Tutorial Online

Live templates for TypeScript to create fluent builders and provide supporting templates

Live templates for TypeScript to create fluent builders and provide supporting templates

Typescript Fluent Builder Live Templates

Live templates for TypeScript to create fluent builders and provide supporting templates.

Templates

This plugin provides the following templates:

builder

Is a basic builder template which can expanded.

Template:

export class $builderName$ {
    constructor(builderFunction: (builder: $builderName$) => void = (e) => e) {
        builderFunction(this);
    }

    build(): $entity$ {
        return {} as $entity$;
    }
}

Example usage:

withField

Template:

    with$fieldName$($fieldNameLower$: $type$): $currentBuilderName$ {
        this.$fieldNameLower$ = $fieldNameLower$;
        return this;
    }

Example usage:

withBuild

Template:

 with$entityName$(
        builderFunction: (builder: $entityName$Builder) => void = (e) => e
    ): $currentBuilder$ {
        builderFunction(this.$entityNameDecaps$Builder);
        return this;
    }

Example usage:

withNull

Template:

    with$entityName$(
        builderFunction: (builder: $entityName$Builder) => void = (e) => e
    ): $currentBuilder$ {
        const newBuilder = new $entityName$Builder();
        builderFunction(newBuilder);
        this.$entityNameDecaps$Builder = newBuilder;
        return this;
    }

Example usage:

withArr

Template:

    with$entityName$(builderFunction: (builder: $entityName$Builder) => void = e => e): $currentBuilderName$ {
        const newBuilder = new $entityName$Builder();
        builderFunction(newBuilder);
        this.$builderArray$Builders.push(newBuilder);
        return this;
     }

Example usage:

GitHub

View Github

Exit mobile version