It's possible to compile and run node successfully with go-mobile after merging https://github.com/status-im/status-go/pull/444
It's possible to pass an object from ObjC to Status Mobile instance written in Go. Check this out:
// mobile.go
// SignalBus is an object that can receive signals.
// signal can be even a struct.
type SignalBus interface {
SendSignal(signal string)
}
// NewMobile creates a new Mobile instance
// that can start a node etc.
func NewMobile(bus) *Mobile {
return &Mobile{bus}
}
// StartNodeAsync starts a node asynchronously.
// When it's started, it sends a signal.
func (m *Mobile) StartNodeAsync(rawConfig string) error {
config, err := params.LoadNodeConfig(rawConfig)
if err != nil {
return err
}
nodeStarted, err := m.api.StartNodeAsync(config)
go func() {
<-nodeStarted
m.bus.SendSignal("node started")
}()
return err
}
// In Objective-C
StatusdMobile *status = StatusdNewMobile(self);
[status startNodeAsync:config error:&error];
// self passed to StatusdNewMobile implements protocol
// StatusdSignalBus, i.e. this method.
// signal can be a Go struct and it would be used like this:
// switch (signal.type) {
// case StatusdEventNodeReady:
// // do something
- (void)sendSignal:(NSString*)signal {
switch (signal) {
case @"node started":
// do something
break;
}
}
No more sending signals in some random places which are super hard to find and no need to craft some crazy C code. Everything is easy to reason about.
There is a lot of work to be done... And it will require a complete redesign of integration with status-react. However, it will make it much easier to navigate through the whole project...