-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is a TaskIt service associated with a Bloc space.
- Loading branch information
1 parent
a1e6360
commit 365b6db
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
] |