Skip to content

Commit

Permalink
Add TKTBlSpaceService
Browse files Browse the repository at this point in the history
It is a TaskIt service associated with a Bloc space.
  • Loading branch information
tinchodias committed Mar 19, 2024
1 parent a1e6360 commit 365b6db
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions src/Bloc-Taskit/TKTBlSpaceService.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"
I'm a TaskIt service associated with a Bloc space.
"
Class {
#name : #TKTBlSpaceService,
#superclass : #TKTService,
#instVars : [
'space',
'actionBlock'
],
#category : #'Bloc-Taskit-Objects'
}

{ #category : #examples }
TKTBlSpaceService class >> example1 [

| space service |
space := BlSpace new.
space
extent: 100@100;
show.

service := TKTBlSpaceService on: space.

service step: [ space root background: Color random ].
service stepDelay: 250 milliSeconds.
service start.

[ 3 seconds wait.
service stop.
space close ] fork

" We kind of emulate this:
space
enqueueTask:
(BlRepeatedTaskAction new
delay: 250 milliSeconds;
action: [ space root background: Color random ];
yourself)."
]

{ #category : #'instance creation' }
TKTBlSpaceService class >> on: aBlSpace [

^ self basicNew
initializeOn: aBlSpace;
yourself
]

{ #category : #initialization }
TKTBlSpaceService >> initializeOn: aBlSpace [

self initialize.

space := aBlSpace
]

{ #category : #accessing }
TKTBlSpaceService >> name [

^ '{1}/{2}' format: { space. self identityHash }
]

{ #category : #accessing }
TKTBlSpaceService >> step: aBlockClosure [

actionBlock := aBlockClosure
]

{ #category : #stepping }
TKTBlSpaceService >> stepService [

space enqueueTask:
(BlTaskAction new
action: actionBlock;
yourself)
]

0 comments on commit 365b6db

Please sign in to comment.