From 365b6db503dd6177cfe42ef2b9b901f9930f089b Mon Sep 17 00:00:00 2001 From: Martin Dias Date: Tue, 19 Mar 2024 10:59:06 -0300 Subject: [PATCH] Add TKTBlSpaceService It is a TaskIt service associated with a Bloc space. --- src/Bloc-Taskit/TKTBlSpaceService.class.st | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/Bloc-Taskit/TKTBlSpaceService.class.st diff --git a/src/Bloc-Taskit/TKTBlSpaceService.class.st b/src/Bloc-Taskit/TKTBlSpaceService.class.st new file mode 100644 index 000000000..0caf2a5cb --- /dev/null +++ b/src/Bloc-Taskit/TKTBlSpaceService.class.st @@ -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) +]