Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:00:38+00:00 2026-05-22T16:00:38+00:00

I use a unit of work pattern a lot in my flex projects. I’ll

  • 0

I use a unit of work pattern a lot in my flex projects. I’ll have a class that might call a web service, put the data in a sqlite db, refresh a model with the data then raise an event.

I usually call these inline and pass in some singleton classes:

protected function CareerSynced():void
    {
        var process:ProcessWorkouts = new ProcessWorkouts(_dataModel, _trainerModel, _databaseCache, _database.Conn);
        process.addEventListener("AllWorkoutsProcessed", AllWorkoutsProcessed);
        process.UpdateAllUnprocessed();
    }

I’ll then get the response like this:

private function AllWorkoutsProcessed(event:DataReceivedEvent):void
    {
    //do something here 
    }

My question is, am I adding that event listener correctly? I think I might be causing a memory leak, but I’m not sure. I’ve also thought about using a weak reference. I’m confused about when to use them. Would this be one of those cases?

Should it be like this?

process.addEventListener("AllWorkoutsProcessed", AllWorkoutsProcessed,false, 0, true);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:00:39+00:00Added an answer on May 22, 2026 at 4:00 pm

    I would either go with the weak reference or just remove the listener:

    private function AllWorkoutsProcessed(event:DataReceivedEvent):void
    {
         event.target.removeEventListener("AllWorksoutsProcessed",AllWorkoutsProcessed);
    }
    

    I could list out my reasons but I’ll just point you to this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How should I use the unit of work pattern in the following scenario: I'm
When I use the unit of work pattern (with JPA), I get an entity
I'm trying to use PHPUnit to unit test some class methods that return SQL.
I personally don't use FxCop yet. We want to work out the unit testing
How do I write a unit test for a method that use an external
I'm currently researching how to add the Unit of Work pattern to my existing
I need to use the ReSharper Unit Test Runner to run my MSTest Unit
I'm using IntelliJ-Idea to write Java daemons. We use JUnit to unit test our
I use the Boost Test framework to unit test my C++ code and wondered
Many people use Mock Objects when they are writing unit tests. What is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.