Integrating Effect with EventEmitter in TypeScript

Does Effect integrate with EventEmitter?

I am using a library that relies on the EventEmitter class, and I'm wondering how to effectively integrate Effect in such scenarios. For example, consider the following code:

import { Effect } from "effect";
const SteamUser = require('steam-user');
const client = new SteamUser();

// Listen for the 'loggedOn' event
client.on('loggedOn', async () => {
    console.log('Successfully logged in to Steam!');

    // Perform additional actions after login
    try {
        const profileInfo = await client.getPersonas([client.steamID]);
        console.log('Profile Info:', profileInfo);
    } catch (error) {
        console.error('Error fetching profile info:', error);
    }
});

// Log in to Steam with credentials
client.logOn({
    accountName: 'account_name',
    password: 'password',
});


How can I rewrite the above code using Effect to handle EventEmitter events?
Was this page helpful?