feat: add example

This commit is contained in:
Victor Wanderley Barbosa
2024-07-02 20:46:17 +02:00
parent 19cf041aa2
commit 64cd2da8fe
2 changed files with 27 additions and 1 deletions
@@ -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
}
}
+2
View File
@@ -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