Giter Club home page Giter Club logo

Comments (3)

jochasinga avatar jochasinga commented on August 15, 2024

Hi @LucasZanella. Do is currently not implemented, but I'll look into it.

What you wanted to do can be achieved with

// wrap a side effect in an EventHandler
handler := handlers.NextFunc(func(v interface{}) {
        fmt.Println(v)
})
sc := observable.Just(1).Subscribe(handler)
<-sc

// or ...

// wrap the side effect in a MappableFunc and throw away the returned Observable
_ = observable.Just(1).Map(func(v interface{}) interface{} {
        fmt.Print(v)
        return nil
})

Go has no generic functions, so it is not possible for a method to accept any function outside of the typed ones declared in fx and handlers.

from rxgo.

jochasinga avatar jochasinga commented on August 15, 2024

@LucasZanella worth checking out this discussion on stackoverflow.

It might be interesting to have Do as a shortcut operator for a subscription in Connectable though, since it is a cold Observable that doesn't fire the stream on Subscribe:

printFunc := func(item interface{}) {
        fmt.Print(item)
}
c := connectable.Just(1).Subscribe(handlers.NextFunc(printFunc))
results := c.Connect()
<-results

// can be
results = connectable.Just(1).Do(printFunc).Connect()
<-results

from rxgo.

jochasinga avatar jochasinga commented on August 15, 2024

Fixed -> Implement Do Operator

from rxgo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.