示例#1
0
 async def test():
     g = gully.Gully()
     observer = g.watch(watch)
     await g.push(1)
     observer.disable()
     await g.push(2)
     observer.enable()
     await g.push(3)
示例#2
0
    async def test():
        g = gully.Gully()
        for _ in range(100_000):

            async def watch(item):
                nonlocal c
                c += 1

            g.watch(watch)
示例#3
0
    async def test():
        g = gully.Gully()

        g.add_mapping(lambda item: item % 2 == 0)

        for i in range(1, 4):
            await g.push(i)

        return g.history
示例#4
0
    async def test():
        g = gully.Gully()

        g.add_filter(lambda item: item % 3 == 0, lambda item: item % 5 == 0)

        for i in range(1, 16):
            await g.push(i)

        return g.history
示例#5
0
    async def test():
        g = gully.Gully()

        g.add_mapping(lambda item: item % 2 == 0, lambda item: "Even"
                      if item else "Odd")

        for i in range(1, 4):
            await g.push(i)

        return g.history
示例#6
0
    async def test():
        g1 = gully.Gully(filters=[lambda item: item % 3 == 0])
        g2 = g1.map(
            lambda item: item % 2 == 0,
            lambda item: "Even" if item else "Odd",
        )

        for i in range(1, 10):
            await g1.push(i)

        await NoOp

        return g1.history, g2.history
示例#7
0
 async def test():
     g = gully.Gully()
     g.watch(watch)
     for i in range(100_000):
         await g.push(i)
示例#8
0
 async def test():
     g = gully.Gully()
     g.watch(watch)
     await g.push("testing")
     await g.push("foobar")
示例#9
0
 async def test():
     g1 = gully.Gully()
     g2 = gully.Gully(g1)
     g2.watch(watch)
     await g1.push(1)
     await NoOp