Skip to content

Commit

Permalink
Add Beacon signal views and print methods [feenkcom/gtoolkit#3908]
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajKubelka committed Jul 26, 2024
1 parent 24cdffe commit 0882c67
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ BrAsyncElementFutureCompletedSuccessfullySignal class >> gtNormalOperationSignal
^ true
]

{ #category : #'gt-extensions' }
BrAsyncElementFutureCompletedSuccessfullySignal >> gtPromiseFor: aView [
<gtView>
self promise ifNil: [ ^ aView empty ].

^ aView forward
title: 'Promise';
priority: 20;
object: [ self promise ];
view: #gtPromiseFor:
]

{ #category : #accessing }
BrAsyncElementFutureCompletedSuccessfullySignal >> isCurrentPromise [
^ isCurrentPromise
Expand Down
10 changes: 8 additions & 2 deletions src/Brick-Core/BrAsyncElementPromise.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ BrAsyncElementPromise >> privateDataSnapshot: aDataSnapshot synchronous: isSynch
isSynchronous
ifTrue: [ self privateUpdateElement ]
ifFalse: [
(BrAsyncElementPromiseRequestUpdateSignal forElement: updater element) emit.
(BrAsyncElementPromiseRequestUpdateSignal forElement: updater element)
promise: promise;
dataSnapshot: aDataSnapshot;
emit.
updater requestUpdate ]
]

Expand Down Expand Up @@ -99,7 +102,10 @@ BrAsyncElementPromise >> privateInitializeElement [
BrAsyncElementPromise >> privateUpdateElement [
"Must be called from the UI thread"

(BrAsyncElementPromiseElementUpdateSignal forElement: updater element) emit.
(BrAsyncElementPromiseElementUpdateSignal forElement: updater element)
promise: promise;
dataSnapshot: dataSnapshot;
emit.

dataSnapshot
ifSuccess: [ :aData | whenSuccess ifNotNil: [ :aBlock | aBlock cull: updater element cull: aData ] ]
Expand Down
15 changes: 12 additions & 3 deletions src/Brick-Core/BrAsyncElementPromiseSignal.class.st
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Class {
#name : #BrAsyncElementPromiseSignal,
#superclass : #BeaconSignal,
#superclass : #ContextStackSignal,
#instVars : [
'element',
'promise',
'spaceTasks',
'elementTasks',
'dataSnapshot'
'dataSnapshot',
'isAttachedToSceneGraph'
],
#category : #'Brick-Core-Futures'
}
Expand Down Expand Up @@ -56,12 +57,20 @@ BrAsyncElementPromiseSignal >> elementTasks [
^ elementTasks
]

{ #category : #accessing }
BrAsyncElementPromiseSignal >> isAttachedToSceneGraph [
^ isAttachedToSceneGraph
]

{ #category : #accessing }
BrAsyncElementPromiseSignal >> prepareForDelivery [
super prepareForDelivery.

element ifNil: [ ^ self ].

spaceTasks := (element space ifNotNil: [ :s | s taskQueue tasks ]).
elementTasks := element taskQueue tasks
elementTasks := element taskQueue tasks.
isAttachedToSceneGraph := element isAttachedToSceneGraph
]

{ #category : #accessing }
Expand Down
13 changes: 11 additions & 2 deletions src/Brick-Editor/BrTextEditorSignal.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ Class {
#name : #BrTextEditorSignal,
#superclass : #BeaconSignal,
#instVars : [
'textEditor'
'textEditor',
'text'
],
#category : 'Brick-Editor-Signals'
#category : #'Brick-Editor-Signals'
}

{ #category : #testing }
Expand All @@ -20,6 +21,14 @@ BrTextEditorSignal class >> textEditor: aBrTextEditor [
^ self new textEditor: aBrTextEditor
]

{ #category : #initialization }
BrTextEditorSignal >> prepareForDelivery [
super prepareForDelivery.

self textEditor ifNotNil: [ :anEditor |
text := anEditor text copy ]
]

{ #category : #accessing }
BrTextEditorSignal >> textEditor [
^ textEditor
Expand Down

0 comments on commit 0882c67

Please sign in to comment.