flush_rewrite_rules() not working with update_option_{$option}

flush_rewrite_rules() should be called very early within the WordPress initialization. The reason is that the entpoints cannot be changed afterwards.

A solution could look like this:

function updateMySlugOption($old_value, $value, $option) {
    if( $old_value != $value ) {
        set_transient('update_slugs', 1);
    }
}
add_action( 'update_option_mySlug', 'updateMySlugOption', 10, 3);

function update_slugs() {
    if( get_transient('update_slugs') ) {
        flush_rewrite_rules();
        delete_transient('update_slugs');
    }
}
add_action('init', 'update_slugs');