Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libs/core/codal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ void registerWithDal(int id, int event, Action a, int flags) {
registerGCPtr(a);
}

void unregisterWithDal(int id, int event, Action a) {
uBit.messageBus.ignore(id, event, dispatchForeground, a);
decr(a);
unregisterGCPtr(a);
}


void fiberDone(void *a) {
decr((Action)a);
unregisterGCPtr((Action)a);
Expand Down
12 changes: 12 additions & 0 deletions libs/core/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

extern uint32_t __StackTop;

namespace pxt {
void unregisterWithDal(int id, int event, Action a);
}

/**
* How to create the event.
*/
Expand Down Expand Up @@ -312,6 +316,14 @@ namespace control {
registerWithDal(src, value, handler, (int)flags);
}

/**
* Removes an event handler binding.
*/
//%
void removeEventBinding(int src, int value, Action handler) {
unregisterWithDal(src, value, handler);
}

/**
* Gets the value of the last event executed on the bus
*/
Expand Down
Loading