feat: add example
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { send, Base, type SendResult } from '../../index'
|
||||
import { send, Base, type SendResult, Detach } from '../../index'
|
||||
import { times } from '#lodash'
|
||||
|
||||
interface ExampleAppWindow extends Window {
|
||||
@@ -108,6 +108,11 @@ function generateTestObject() {
|
||||
.fill(0)
|
||||
.map(() => new RandomFoo({ bar: 'baz baz baz' }))
|
||||
],
|
||||
detachedWithDecorator: new Collection<RandomFoo>('Collection of Foo', 'Foo', [
|
||||
...Array(10)
|
||||
.fill(0)
|
||||
.map(() => new RandomFoo())
|
||||
]),
|
||||
'@(10)chunkedArr': times(100, () => 42)
|
||||
})
|
||||
}
|
||||
@@ -118,3 +123,22 @@ class RandomFoo extends Base {
|
||||
this.noise = Math.random().toString(16)
|
||||
}
|
||||
}
|
||||
|
||||
export class Collection<T extends Base> extends Base {
|
||||
@Detach()
|
||||
elements: T[]
|
||||
// eslint-disable-next-line camelcase
|
||||
speckle_type = 'Speckle.Core.Models.Collection'
|
||||
|
||||
constructor(
|
||||
name: string,
|
||||
collectionType: string,
|
||||
elements: T[] = [],
|
||||
props?: Record<string, unknown>
|
||||
) {
|
||||
super(props)
|
||||
this.name = name
|
||||
this.collectionType = collectionType
|
||||
this.elements = elements
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { ServerTransport } from './transports/ServerTransport'
|
||||
import { Base } from './utils/Base'
|
||||
export { Base }
|
||||
|
||||
export { Detach } from './utils/Decorators'
|
||||
|
||||
export type SendParams = {
|
||||
serverUrl?: string
|
||||
projectId: string
|
||||
|
||||
Reference in New Issue
Block a user