You're viewing archived documentation for @imqueue/rpc v1.17.1. APIs may differ from the current release. View the latest version ↗

property() function

Implements '@property' decorator factory This is used to specify complex service types to be exposed

Signature:

export declare function property(type: string | Thunk | any, isOptional?: boolean): any;

Parameters

Parameter

Type

Description

type

string | Thunk | any

isOptional

boolean

(Optional)

Returns:

any

Example

~~~typescript import { property, expose, IMQService } from '@imqueue/rpc';

class Address { @property('string') country: string;

@property('string') city: string;

@property('string') address: string;

@property('string', true) zipCode?: string; // this is optional }

class User { @property('string') firstName: string;

@property('string') lastName: string;

@property('string') email: string;

@property('Array

', true) address?: Array
; }

// now we can use those complex types as service methods args // and them will be properly exposed to service clients

class UserService extends IMQService {

@expose() public save(user: User)

@expose() public find(id: number): User

} ~~~

{( target: any, methodName: (string), descriptor: TypedPropertyDescriptor<(...args: any[]) => any> ) => void}