fengb / zCord

Zig ⚡ Discord API with zero allocations in the critical path
MIT License
53 stars 11 forks source link

API revamp — iterators not callbacks #11

Closed fengb closed 2 years ago

fengb commented 2 years ago
const client = zCord.Client.init(auth);
const gateway = try client.startGateway(.{
    .allocator = &gpa.allocator,
    .intents = .{},
    .auto_reconnect = true,
});
defer gateway.destroy();

while (true) {
    switch (try gateway.recvEvent()) {
        .connect => {},
        .dispatch => |dispatch| {
            // dispatch.seq, dispatch.name, dispatch.data
        },
    }
}

Advantages:

Disadvantages:

fengb commented 2 years ago

Minor disadvantage:

Disadvantage averted: